InterchangesDelegator extends BaseDelegator implements IInterchangesDelegator { @Override public List<IChangelist> getInterchanges(final IFileSpec fromFile, final IFileSpec toFile, final GetInterchangesOptions opts) throws P4JavaException { List<IFileSpec> files = new ArrayList<>(); files.add(fromFile); files.add(toFile); List<Map<String, Object>> resultMaps = execMapCmdList(INTERCHANGES, processParameters(opts, files, server), null); return processInterchangeMaps(resultMaps, InterchangesDelegatorHidden.isListIndividualFilesThatRequireIntegration(opts)); } InterchangesDelegator(IOptionsServer server); @Override List<IChangelist> getInterchanges(final IFileSpec fromFile, final IFileSpec toFile,
            final GetInterchangesOptions opts); @Override List<IChangelist> getInterchanges(final String branchSpecName,
            final List<IFileSpec> fromFileList, final List<IFileSpec> toFileList,
            final GetInterchangesOptions opts); List<IChangelist> getInterchanges(final IFileSpec fromFile, final IFileSpec toFile,
            final boolean showFiles, final boolean longDesc, final int maxChangelistId); List<IChangelist> getInterchanges(final String branchSpecName,
            final List<IFileSpec> fromFileList, final List<IFileSpec> toFileList,
            final boolean showFiles, final boolean longDesc, final int maxChangelistId,
            final boolean reverseMapping, final boolean biDirectional); List<IChangelist> processInterchangeMaps(final List<Map<String, Object>> resultMaps,
            final boolean showFiles);  }
@Test(expected=ConnectionException.class) public void testConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(ConnectionException.class); interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); }
@Test(expected=AccessException.class) public void testAccessException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(AccessException.class); interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); }
@Test(expected=RequestException.class) public void testRequestException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(RequestException.class); interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); }
@Test(expected=RequestException.class) public void tetsP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(P4JavaException.class); interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); }
@Test public void testLongDescription() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[] { "-f", "-l", "-C100" })), eq((Map<String, Object>) null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> interchanges = interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); assertEquals(1, interchanges.size()); assertEquals(10, interchanges.get(0).getId()); }
@Test(expected=ConnectionException.class) public void testBranchConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(ConnectionException.class); interchangesDelegator.getInterchanges("myBranch", fromList, toList, true, true, 100, true, true); }
@Test(expected=AccessException.class) public void testBranchAccessException() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(AccessException.class); interchangesDelegator.getInterchanges("myBranch", fromList, toList, true, true, 100, true, true); }
@Test(expected=RequestException.class) public void testRequestExceptionWithBranch() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(RequestException.class); interchangesDelegator.getInterchanges("myBranch", fromList, toList, true, true, 100, true, true); }
@Test(expected=RequestException.class) public void testP4JavaExceptionWithBranch() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), any(String[].class), eq((Map<String, Object>) null))).thenThrow(P4JavaException.class); interchangesDelegator.getInterchanges("myBranch", fromList, toList, true, true, 100, true, true); }
@Test public void testBranchInterchanges() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[] { "-b", "myBranch" })), eq((Map<String, Object>) null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> changelists = interchangesDelegator.getInterchanges("myBranch", fromList, toList, mockOpts); assertEquals(1, changelists.size()); assertEquals(10, changelists.get(0).getId()); }
@Test public void testBranchInterchangesWithFilters() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher( new String[] { "-f", "-l", "-C100", "-r", "-b", "myBranch", "-s" })), eq((Map<String, Object>) null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IFileSpec> from = new ArrayList<IFileSpec>(); from.add(mockFromFile); List<IFileSpec> to = new ArrayList<IFileSpec>(); to.add(mockToFile); List<IChangelist> interchanges = interchangesDelegator.getInterchanges("myBranch", from, to, true, true, 100, true, true); assertEquals(1, interchanges.size()); }
@Test public void testInterchanges() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[0])), eq((Map<String, Object>) null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> interchanges = interchangesDelegator.getInterchanges(mockFromFile, mockToFile, mockOpts); assertEquals(1, interchanges.size()); assertEquals(10, interchanges.get(0).getId()); }
@Test public void testLongDescription() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[] { "-f", "-l", "-C100" })), eq(null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> interchanges = interchangesDelegator.getInterchanges(mockFromFile, mockToFile, true, true, 100); assertEquals(1, interchanges.size()); assertEquals(10, interchanges.get(0).getId()); }
@Test public void testBranchInterchanges() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[] { "-b", "myBranch" })), eq(null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> changelists = interchangesDelegator.getInterchanges("myBranch", Lists.newArrayList(mockFromFile), Lists.newArrayList(mockToFile), mockOpts); assertEquals(1, changelists.size()); assertEquals(10, changelists.get(0).getId()); }
@Test public void testBranchInterchangesWithFilters() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher( new String[] { "-f", "-l", "-C100", "-r", "-b", "myBranch", "-s" })), eq(null))).thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> interchanges = interchangesDelegator.getInterchanges("myBranch", Lists.newArrayList(mockFromFile), Lists.newArrayList(mockToFile), true, true, 100, true, true); assertEquals(1, interchanges.size()); }
@Test public void testInterchanges() throws P4JavaException { when(server.execMapCmdList(eq(INTERCHANGES.toString()), argThat(new CommandLineArgumentMatcher(new String[0])), eq(null))) .thenReturn(resultMaps); when(resultMap.get("change")).thenReturn("10"); List<IChangelist> interchanges = interchangesDelegator.getInterchanges(mockFromFile, mockToFile, mockOpts); assertEquals(1, interchanges.size()); assertEquals(10, interchanges.get(0).getId()); }