ClientDelegator extends BaseDelegator implements IClientDelegator { @Override public String deleteClient(final String clientName, final boolean force) throws ConnectionException, RequestException, AccessException { try { return deleteClient(clientName, new DeleteClientOptions(force)); } catch (final ConnectionException | AccessException | RequestException exc) { throw exc; } catch (P4JavaException exc) { throw new RequestException(exc.getMessage(), exc); } } ClientDelegator(IOptionsServer server); @Override IClient getClient(final String clientName); @Override IClient getClient(@Nonnull IClientSummary clientSummary); @Override IClient getClientTemplate(String clientName); @Override IClient getClientTemplate(final String clientName, final boolean allowExistent); @Override IClient getClientTemplate(
			@Nonnull String clientName,
			GetClientTemplateOptions getClientTemplateOptions); @Override String createClient(@Nonnull final IClient newClient); @Override void createTempClient(@Nonnull final IClient newClient); @Override String updateClient(@Nonnull final IClient client); @Override String updateClient(@Nonnull final IClient client, final boolean force); @Override String updateClient(@Nonnull final IClient client, final UpdateClientOptions opts); @Override String deleteClient(final String clientName, final boolean force); @Override String deleteClient(final String clientName, final DeleteClientOptions opts); String switchClientView(final String templateClientName,
								   final String targetClientName,
								   final SwitchClientViewOptions opts); @Override String switchStreamView(final String streamPath,
								   final String targetClientName,
								   final SwitchClientViewOptions opts);  }
@Test public void deleteClient_byClientNameAndForce_shouldReturnDeletedClientName() throws Exception { doReturn(clientName).when(clientDelegator) .deleteClient(any(String.class), any(DeleteClientOptions.class)); String actualClientName = clientDelegator.deleteClient(clientName, false); assertThat(actualClientName, is(clientName)); }
@Test public void deleteClient_byClientNameAndDeleteClientOptions_shouldThrownIllegalArgumentExceptionWhenClientNameIsBlank() throws Exception { thrown.expect(IllegalArgumentException.class); clientDelegator.deleteClient(EMPTY, mock(DeleteClientOptions.class)); }
@Test public void deleteClient_byClientNameAndDeleteClientOptions_shouldReturnNonNullDeletedClientName() throws Exception { when(server.execMapCmdList( eq(CLIENT.toString()), any(String[].class), any())) .thenReturn(resultMaps); givenInfoMessageResultMap(); String actualClientName = clientDelegator.deleteClient( clientName, mock(DeleteClientOptions.class)); assertThat(actualClientName, is(clientName)); }
@Test(expected = ConnectionException.class) public void deleteClient_byClientNameAndForce_shouldThrownConnectionExceptionThatWasThrownInnerDeleteClient() throws Exception { doThrow(ConnectionException.class).when(clientDelegator).deleteClient(any(String.class), any(DeleteClientOptions.class)); clientDelegator.deleteClient(clientName, false); }
@Test(expected = AccessException.class) public void deleteClient_byClientNameAndForce_shouldThrownAccessExceptionThatWasThrownInnerDeleteClient() throws Exception { doThrow(AccessException.class).when(clientDelegator).deleteClient(any(String.class), any(DeleteClientOptions.class)); clientDelegator.deleteClient(clientName, false); }
@Test(expected = RequestException.class) public void deleteClient_byClientNameAndForce_shouldThrownRequestExceptionThatWasThrownInnerDeleteClient() throws Exception { doThrow(RequestException.class).when(clientDelegator).deleteClient(any(String.class), any(DeleteClientOptions.class)); clientDelegator.deleteClient(clientName, false); }
@Test(expected = RequestException.class) public void deleteClient_byClientNameAndForce_shouldThrownRequestExceptionWhenP4JavaExceptionWasThrown() throws Exception { doThrow(P4JavaException.class).when(clientDelegator).deleteClient(any(String.class), any(DeleteClientOptions.class)); clientDelegator.deleteClient(clientName, false); }
@Test public void deleteClient_byClientNameAndForce_shouldReturnDeletedClientName() throws Exception { doReturn(clientName).when(clientDelegator).deleteClient(any(String.class), any(DeleteClientOptions.class)); String actualClientName = clientDelegator.deleteClient(clientName, false); assertThat(actualClientName, is(clientName)); }
@Test(expected = IllegalArgumentException.class) public void deleteClient_byClientNameAndDeleteClientOptions_shouldThrownIllegalArgumentExceptionWhenClientNameIsBlank() throws Exception { clientDelegator.deleteClient(EMPTY, mock(DeleteClientOptions.class)); }
@SuppressWarnings("unchecked") @Test public void deleteClient_byClientNameAndDeleteClientOptions_shouldReturnNonNullDeletedClientName() throws Exception { when(server.execMapCmdList(eq(CLIENT.toString()), any(String[].class), (Map<String, Object>) any())).thenReturn(resultMaps); givenInfoMessageResultMap(); String actualClientName = clientDelegator.deleteClient(clientName, mock(DeleteClientOptions.class)); assertThat(actualClientName, is(clientName)); }