FixesDelegator extends BaseDelegator implements IFixesDelegator { @Override public List<IFix> getFixList(final List<IFileSpec> fileSpecs, final int changeListId, final String jobId, final boolean includeIntegrations, final int maxFixes) throws ConnectionException, RequestException, AccessException { try { int resolvedChangelistId = changeListId; if (changeListId == IChangelist.DEFAULT) { resolvedChangelistId = IChangelist.UNKNOWN; } GetFixesOptions getFixesOptions = new GetFixesOptions() .setChangelistId(resolvedChangelistId) .setIncludeIntegrations(includeIntegrations).setJobId(jobId) .setMaxFixes(maxFixes); return getFixes(fileSpecs, getFixesOptions); } catch (final ConnectionException | AccessException | RequestException exc) { throw exc; } catch (P4JavaException exc) { throw new RequestException(exc.getMessage(), exc); } } FixesDelegator(final IOptionsServer server); @Override List<IFix> getFixList(final List<IFileSpec> fileSpecs, final int changeListId,
            final String jobId, final boolean includeIntegrations, final int maxFixes); @Override List<IFix> getFixes(final List<IFileSpec> fileSpecs, final GetFixesOptions opts);  }
@Test(expected = AccessException.class) public void testFixesJobsAccessException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = ConnectionException.class) public void testFixesJobsConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = AccessException.class) public void testFixesJobsAccessException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = RequestException.class) public void testFixesJobsRequestException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = P4JavaException.class) public void testFixesJobsP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test public void getFixListEmpty() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildEmptyResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null)); assertNotNull(fixes); assertEquals(0, fixes.size()); }
@Test public void getFixList() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null)); assertFixes(fixes); }
@Test public void getFixListDefault() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_UNKNOWN_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Changelist.DEFAULT, TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_UNKNOWN_MATCHER), eq((Map<String, Object>)null)); assertFixes(fixes); }
@Test(expected = ConnectionException.class) public void testFixesJobsConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenThrow(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = AccessException.class) public void testFixesJobsAccessException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenThrow(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = RequestException.class) public void testFixesJobsRequestException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenThrow(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test(expected = P4JavaException.class) public void testFixesJobsP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenThrow(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); }
@Test public void getFixListEmpty() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenReturn(buildEmptyResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null)); assertNotNull(fixes); assertEquals(0, fixes.size()); }
@Test public void getFixList() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Integer.valueOf(TEST_CHANGELIST), TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null)); assertFixes(fixes); }
@Test public void getFixListDefault() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_UNKNOWN_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixList(specs, Changelist.DEFAULT, TEST_JOB_123, true, 0); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_UNKNOWN_MATCHER), eq(null)); assertFixes(fixes); }