DepotDelegator extends BaseDelegator implements IDepotDelegator { @Override public IDepot getDepot(final String name) throws P4JavaException { Validate.notBlank(name, "Depot name shouldn't null or empty"); List<Map<String, Object>> resultMaps = execMapCmdList(DEPOT, new String[]{"-o", name}, null); return ResultListBuilder.buildNullableObjectFromNonInfoMessageCommandResultMaps( resultMaps, new Function<Map<String, Object>, IDepot>() { @Override public IDepot apply(Map<String, Object> map) { return new Depot(map); } } ); } DepotDelegator(final IOptionsServer server); @Override String createDepot(@Nonnull final IDepot newDepot); @Override String deleteDepot(final String name); @Override IDepot getDepot(final String name);  }
@Test public void testGetDepot() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(GET_MATCHER), eq(null))) .thenReturn(buildGetMap()); IDepot result = depotDelegator.getDepot(TEST_DEPOT); verify(server).execMapCmdList(eq(DEPOT.toString()), argThat(GET_MATCHER), eq(null)); assertEquals(TEST_DEPOT, result.getName()); assertEquals(TEST_USER, result.getOwnerName()); assertEquals(TEST_DEPOT_DESC, result.getDescription()); assertEquals(TEST_DEPOT_MAP, result.getMap()); assertEquals(DepotType.SPEC, result.getDepotType()); }
@Test(expected = AccessException.class) public void testGetAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(GET_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); depotDelegator.getDepot(TEST_DEPOT); }
@Test(expected = ConnectionException.class) public void testGetConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(GET_MATCHER), eq(null))) .thenThrow(ConnectionException.class); depotDelegator.getDepot(TEST_DEPOT); }
@Test(expected = RequestException.class) public void testGetRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(GET_MATCHER), eq(null))) .thenThrow(RequestException.class); depotDelegator.getDepot(TEST_DEPOT); }