ClientDelegator extends BaseDelegator implements IClientDelegator { @Override public String createClient(@Nonnull final IClient newClient) throws ConnectionException, RequestException, AccessException { Validate.notNull(newClient); replaceWithUnderscoreIfClientNameContainsWhitespacesOrTabs(newClient); List<Map<String, Object>> resultMaps = execMapCmdList( CLIENT, new String[]{"-i"}, InputMapper.map(newClient)); return parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } 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 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 createClient_shouldThrowNullPointExceptionWhenClientIsNull() throws Exception { expectThrows(NullPointerException.class, () -> clientDelegator.createClient(null)); }
@Test public void createClient_shouldThrowConnectionExceptionThatWasThrownFromParseCommandResultMapIfIsInfoMessageAsString() throws Exception { doThrow(ConnectionException.class) .when(server) .execMapCmdList(eq(CLIENT.toString()), eq(new String[]{"-i"}), any(Map.class)); expectThrows(ConnectionException.class, () -> clientDelegator.createClient(mockClient)); }
@Test public void createClient_shouldReturnClientName() throws Exception { when(server.execMapCmdList( eq(CLIENT.toString()), eq(new String[]{"-i"}), any(Map.class))).thenReturn(resultMaps); givenInfoMessageResultMap(); String actualClientName = clientDelegator.createClient(mockClient); assertThat(actualClientName, is(clientName)); }