DepotsDelegator extends BaseDelegator implements IDepotsDelegator { @Override public List<IDepot> getDepots() throws ConnectionException, RequestException, AccessException { List<IDepot> metadataArray = new ArrayList<>(); List<Map<String, Object>> resultMaps = execMapCmdList(DEPOTS, new String[0], null); if (nonNull(resultMaps)) { for (Map<String, Object> map : resultMaps) { if (!ResultMapParser.handleErrorStr(map)) { metadataArray.add(new Depot(map)); } } } return metadataArray; } DepotsDelegator(final IOptionsServer server); @Override List<IDepot> getDepots();  }
@Test(expected = AccessException.class) public void testGetAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); depotsDelegator.getDepots(); }
@Test public void testGetDepots() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildDepotsMap()); List<IDepot> result = depotsDelegator.getDepots(); verify(server).execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null)); assertNotNull(result); assertEquals(1, result.size()); IDepot depot = result.get(0); assertEquals(TEST_DEPOT, depot.getName()); assertEquals(TEST_DEPOT_DESC, depot.getDescription()); assertEquals(TEST_DEPOT_MAP, depot.getMap()); assertEquals(DepotType.SPEC, depot.getDepotType()); }
@Test public void testGetDepotsNonFound() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildNoDepotsMap()); List<IDepot> result = depotsDelegator.getDepots(); verify(server).execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null)); assertNotNull(result); assertEquals(0, result.size()); }
@Test(expected = AccessException.class) public void testGetAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null))) .thenThrow(AccessException.class); depotsDelegator.getDepots(); }
@Test(expected = ConnectionException.class) public void testGetConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null))) .thenThrow(ConnectionException.class); depotsDelegator.getDepots(); }
@Test(expected = RequestException.class) public void testGetRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq((Map<String,Object>)null))) .thenThrow(RequestException.class); depotsDelegator.getDepots(); }
@Test public void testGetDepots() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenReturn(buildDepotsMap()); List<IDepot> result = depotsDelegator.getDepots(); verify(server).execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null)); assertNotNull(result); assertEquals(1, result.size()); IDepot depot = result.get(0); assertEquals(TEST_DEPOT, depot.getName()); assertEquals(TEST_DEPOT_DESC, depot.getDescription()); assertEquals(TEST_DEPOT_MAP, depot.getMap()); assertEquals(DepotType.SPEC, depot.getDepotType()); }
@Test public void testGetDepotsNonFound() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenReturn(buildNoDepotsMap()); List<IDepot> result = depotsDelegator.getDepots(); verify(server).execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null)); assertNotNull(result); assertEquals(0, result.size()); }
@Test(expected = AccessException.class) public void testGetAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenThrow(AccessException.class); depotsDelegator.getDepots(); }
@Test(expected = ConnectionException.class) public void testGetConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenThrow(ConnectionException.class); depotsDelegator.getDepots(); }
@Test(expected = RequestException.class) public void testGetRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOTS.toString()), argThat(EMPTY_MATCHER), eq(null))) .thenThrow(RequestException.class); depotsDelegator.getDepots(); }