DepotDelegator extends BaseDelegator implements IDepotDelegator { @Override public String deleteDepot(final String name) throws P4JavaException { Validate.notBlank(name, "Delete depot name shouldn't null or empty"); List<Map<String, Object>> resultMaps = execMapCmdList(DEPOT, new String[]{"-d", name}, null); 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 testDeleteAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test public void testDeleteDepot() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildDepotDeletedMap()); String result = depotDelegator.deleteDepot(TEST_DEPOT); verify(server).execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null)); assertEquals("Depot " + TEST_DEPOT + " deleted.", result); }
@Test public void testDeleteDepotNotEmpty() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null))) .thenReturn(buildDepotNotEmptyMap()); try { depotDelegator.deleteDepot(TEST_DEPOT); } catch (RequestException e) { assertTrue(e.getMessage().startsWith("Depot " + TEST_DEPOT + " isn't empty.")); } }
@Test(expected = AccessException.class) public void testDeleteAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null))) .thenThrow(AccessException.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test(expected = ConnectionException.class) public void testDeleteConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null))) .thenThrow(ConnectionException.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test(expected = RequestException.class) public void testDeleteRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq((Map<String,Object>)null))) .thenThrow(RequestException.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test public void testDeleteDepot() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenReturn(buildDepotDeletedMap()); String result = depotDelegator.deleteDepot(TEST_DEPOT); verify(server).execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null)); assertEquals("Depot " + TEST_DEPOT + " deleted.", result); }
@Test public void testDeleteDepotNotEmpty() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenReturn(buildDepotNotEmptyMap()); try { depotDelegator.deleteDepot(TEST_DEPOT); } catch (RequestException e) { assertTrue(e.getMessage().startsWith("Depot " + TEST_DEPOT + " isn't empty.")); } }
@Test(expected = AccessException.class) public void testDeleteAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenThrow(AccessException.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test(expected = ConnectionException.class) public void testDeleteConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenThrow(ConnectionException.class); depotDelegator.deleteDepot(TEST_DEPOT); }
@Test(expected = RequestException.class) public void testDeleteRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DEPOT.toString()), argThat(DELETE_MATCHER), eq(null))) .thenThrow(RequestException.class); depotDelegator.deleteDepot(TEST_DEPOT); }