DepotDelegator extends BaseDelegator implements IDepotDelegator { @Override public String createDepot(@Nonnull final IDepot newDepot) throws P4JavaException { Validate.notNull(newDepot); List<Map<String, Object>> resultMaps = execMapCmdList(DEPOT, new String[]{"-i"}, InputMapper.map(newDepot)); return ResultMapParser.parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } DepotDelegator(final IOptionsServer server); @Override String createDepot(@Nonnull final IDepot newDepot); @Override String deleteDepot(final String name); @Override IDepot getDepot(final String name);  }
@Test(expected = AccessException.class) public void testCreateAccessException() throws P4JavaException { IDepot depot = buildDepot(); when(server.execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot)))).thenThrow(AccessException.AccessExceptionForTests.class); depotDelegator.createDepot(depot); }
@Test(expected = NullPointerException.class) public void testCreateNullDepot() throws P4JavaException { depotDelegator.createDepot(null); }
@Test public void testCreateDepot() throws P4JavaException { IDepot depot = buildDepot(); when(server.execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot)))).thenReturn(buildDepotCreatedMap()); String result = depotDelegator.createDepot(depot); verify(server).execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot))); assertEquals("Depot " + TEST_DEPOT + " saved.", result); }
@Test(expected = AccessException.class) public void testCreateAccessException() throws P4JavaException { IDepot depot = buildDepot(); when(server.execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot)))).thenThrow(AccessException.class); depotDelegator.createDepot(depot); }
@Test(expected = ConnectionException.class) public void testCreateConnectionException() throws P4JavaException { IDepot depot = buildDepot(); when(server.execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot)))).thenThrow(ConnectionException.class); depotDelegator.createDepot(depot); }
@Test(expected = RequestException.class) public void testCreateRequestException() throws P4JavaException { IDepot depot = buildDepot(); when(server.execMapCmdList(eq(DEPOT.toString()), argThat(CREATE_MATCHER), eq(InputMapper.map(depot)))).thenThrow(RequestException.class); depotDelegator.createDepot(depot); }