FixesDelegator extends BaseDelegator implements IFixesDelegator { @Override public List<IFix> getFixes(final List<IFileSpec> fileSpecs, final GetFixesOptions opts) throws P4JavaException { List<Map<String, Object>> resultMaps = execMapCmdList(FIXES, processParameters(opts, fileSpecs, server), null); return ResultListBuilder.buildNonNullObjectListFromCommandResultMaps(resultMaps, new Function<Map, IFix>() { @Override public IFix apply(Map map) { return new Fix(map); } } ); } 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 = ConnectionException.class) public void testFixesJobsOptConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = AccessException.class) public void testFixesJobsOptAccessException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = RequestException.class) public void testFixesJobsOptRequestException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = P4JavaException.class) public void testFixesJobsOptP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test public void getFixListOptEmpty() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildEmptyResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, new GetFixesOptions()); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null)); assertNotNull(fixes); assertEquals(0, fixes.size()); }
@Test public void getFixListOpt() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, new GetFixesOptions()); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq((Map<String, Object>)null)); assertFixes(fixes); }
@Test public void getFixListSpecifiedOpt() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); GetFixesOptions options = new GetFixesOptions(); options.setJobId(TEST_JOB_123); options.setChangelistId(Integer.valueOf(TEST_CHANGELIST)); options.setIncludeIntegrations(true); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, options); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq((Map<String, Object>)null)); assertFixes(fixes); }
@Test public void getFixListSpecifiedOptDefaultList() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_DEFAULT_MATCHER), eq((Map<String, Object>)null))).thenReturn(buildValidResultMap()); GetFixesOptions options = new GetFixesOptions(); options.setJobId(TEST_JOB_123); options.setChangelistId(Integer.valueOf(Changelist.DEFAULT)); options.setIncludeIntegrations(true); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, options); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_DEFAULT_MATCHER), eq((Map<String, Object>)null)); assertFixes(fixes); }
@Test(expected = ConnectionException.class) public void testFixesJobsOptConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenThrow(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = AccessException.class) public void testFixesJobsOptAccessException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenThrow(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = RequestException.class) public void testFixesJobsOptRequestException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenThrow(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test(expected = P4JavaException.class) public void testFixesJobsOptP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenThrow(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); fixesDelegator.getFixes(specs, new GetFixesOptions()); }
@Test public void getFixListOptEmpty() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenReturn(buildEmptyResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, new GetFixesOptions()); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null)); assertNotNull(fixes); assertEquals(0, fixes.size()); }
@Test public void getFixListOpt() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, new GetFixesOptions()); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_MATCHER), eq(null)); assertFixes(fixes); }
@Test public void getFixListSpecifiedOpt() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); GetFixesOptions options = new GetFixesOptions(); options.setJobId(TEST_JOB_123); options.setChangelistId(Integer.valueOf(TEST_CHANGELIST)); options.setIncludeIntegrations(true); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, options); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_MATCHER), eq(null)); assertFixes(fixes); }
@Test public void getFixListSpecifiedOptDefaultList() throws P4JavaException { when(server.execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_DEFAULT_MATCHER), eq(null))).thenReturn(buildValidResultMap()); GetFixesOptions options = new GetFixesOptions(); options.setJobId(TEST_JOB_123); options.setChangelistId(Integer.valueOf(Changelist.DEFAULT)); options.setIncludeIntegrations(true); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFix> fixes = fixesDelegator.getFixes(specs, options); verify(server).execMapCmdList(eq(FIXES.toString()), argThat(FIX_FS_PARAMS_DEFAULT_MATCHER), eq(null)); assertFixes(fixes); }