ChangesDelegator extends BaseDelegator implements IChangesDelegator { @Override public List<IChangelistSummary> getChangelists( final int maxMostRecent, final List<IFileSpec> fileSpecs, final String clientName, final String userName, final boolean includeIntegrated, final Type type, final boolean longDesc) throws ConnectionException, RequestException, AccessException { try { GetChangelistsOptions getChangelistsOptions = new GetChangelistsOptions() .setClientName(clientName) .setIncludeIntegrated(includeIntegrated) .setLongDesc(longDesc) .setMaxMostRecent(maxMostRecent) .setType(type) .setUserName(userName); return getChangelists(fileSpecs, getChangelistsOptions); } catch (final ConnectionException | RequestException | AccessException exc) { throw exc; } catch (P4JavaException exc) { throw new RequestException(exc.getMessage(), exc); } } ChangesDelegator(final IOptionsServer server); @Override List<IChangelistSummary> getChangelists(
            final int maxMostRecent,
            final List<IFileSpec> fileSpecs,
            final String clientName,
            final String userName,
            final boolean includeIntegrated,
            final Type type,
            final boolean longDesc); @Override List<IChangelistSummary> getChangelists(
            final int maxMostRecent,
            final List<IFileSpec> fileSpecs,
            final String clientName,
            final String userName,
            final boolean includeIntegrated,
            final boolean submittedOnly,
            final boolean pendingOnly,
            final boolean longDesc); List<IChangelistSummary> getChangelists(
            final List<IFileSpec> fileSpecs,
            final GetChangelistsOptions opts);  }
@Test public void testGetChangesAccessException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("AccessException was expected."); } catch (AccessException accEx) { } catch (Exception ex) { fail("AccessException was expected."); } }
@Test public void testGetChangesFileSpecEmptyOptions() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq((Map<String,Object>)null))) .thenReturn(null); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(mockFileSpecs, new GetChangelistsOptions()); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 0); }
@Test public void testGetChangesFileSpecOptions() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(mockFileSpecs, new GetChangelistsOptions()); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChanges() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, SUBMITTED, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesNonInt() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", false, SUBMITTED, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesNonIntNonDesc() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_DESC_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", false, SUBMITTED, false); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_DESC_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesArgs() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, true, false, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesArgsNotSubmitted() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NOT_SUB_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null))).thenReturn(buildChangesList("pending")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NOT_SUB_ARGS_PARAMS_MATCHER), eq((Map<String,Object>)null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.PENDING); }
@Test public void testGetChangesAccessException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq((Map<String,Object>)null))) .thenThrow(AccessException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("AccessException was expected."); } catch (AccessException accEx) { } catch (Exception ex) { fail("AccessException was expected."); } }
@Test public void testGetChangesConnectionException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq((Map<String,Object>)null))) .thenThrow(ConnectionException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("ConnectionException was expected."); } catch (ConnectionException e) { } catch (Exception ex) { fail("ConnectionException was expected."); } }
@Test public void testGetChangesRequestException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq((Map<String,Object>)null))) .thenThrow(RequestException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("RequestException was expected."); } catch (RequestException e) { } catch (Exception ex) { fail("RequestException was expected."); } }
@Test public void testGetChangesP4JavaException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq((Map<String,Object>)null))) .thenThrow(P4JavaException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("RequestException was expected."); } catch (RequestException e) { } catch (Exception ex) { fail("RequestException was expected."); } }
@Test public void testGetChangesFileSpecEmptyOptions() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq(null))) .thenReturn(null); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(mockFileSpecs, new GetChangelistsOptions()); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 0); }
@Test public void testGetChangesFileSpecOptions() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq(null))) .thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(mockFileSpecs, new GetChangelistsOptions()); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SPEC_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChanges() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq(null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, SUBMITTED, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesNonInt() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_ARGS_PARAMS_MATCHER), eq(null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", false, SUBMITTED, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_ARGS_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesNonIntNonDesc() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_DESC_ARGS_PARAMS_MATCHER), eq(null))) .thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", false, SUBMITTED, false); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NON_INT_DESC_ARGS_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesArgs() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq(null))).thenReturn(buildChangesList("submitted")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, true, false, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(SERVER_ARGS_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.SUBMITTED); }
@Test public void testGetChangesArgsNotSubmitted() throws P4JavaException { when(server.execMapCmdList(eq(CHANGES.toString()), argThat(NOT_SUB_ARGS_PARAMS_MATCHER), eq(null))).thenReturn(buildChangesList("pending")); List<IChangelistSummary> changeLists = changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); verify(server).execMapCmdList(eq(CHANGES.toString()), argThat(NOT_SUB_ARGS_PARAMS_MATCHER), eq(null)); assertNotNull(changeLists); assertTrue(changeLists.size() == 1); assertChangeListSummary(changeLists.get(0), ChangelistStatus.PENDING); }
@Test public void testGetChangesAccessException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq(null))) .thenThrow(AccessException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("AccessException was expected."); } catch (AccessException accEx) { } catch (Exception ex) { fail("AccessException was expected."); } }
@Test public void testGetChangesConnectionException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq(null))) .thenThrow(ConnectionException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("ConnectionException was expected."); } catch (ConnectionException e) { } catch (Exception ex) { fail("ConnectionException was expected."); } }
@Test public void testGetChangesRequestException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq(null))) .thenThrow(RequestException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("RequestException was expected."); } catch (RequestException e) { } catch (Exception ex) { fail("RequestException was expected."); } }
@Test public void testGetChangesP4JavaException() throws Exception { when(server.execMapCmdList(eq(CHANGES.toString()), any(String[].class), eq(null))) .thenThrow(P4JavaException.class); try { changesDelegator.getChangelists(1, mockFileSpecs, CLIENT, "", true, false, false, true); fail("RequestException was expected."); } catch (RequestException e) { } catch (Exception ex) { fail("RequestException was expected."); } }