SW360ClientConfig { public static SW360ClientConfig createConfig(String restURL, String authURL, String user, String password, String clientId, String clientPassword, String token, HttpClient httpClient, ObjectMapper mapper) { if(!StringUtils.isEmpty(token)){ return new SW360ClientConfig( URI.create(stripTrailingSeparator(Validate.notEmpty(restURL, "Undefined REST URL"))), stripTrailingSeparator(Validate.notEmpty(authURL, "Undefined authentication URL")), user, password, Validate.notEmpty(clientId, "Undefined client ID"), Validate.notEmpty(clientPassword, "Undefined client password"), Validate.notEmpty(token, "Undefined token"), Validate.notNull(httpClient), Validate.notNull(mapper)); } return new SW360ClientConfig( URI.create(stripTrailingSeparator(Validate.notEmpty(restURL, "Undefined REST URL"))), stripTrailingSeparator(Validate.notEmpty(authURL, "Undefined authentication URL")), Validate.notEmpty(user, "Undefined user"), Validate.notEmpty(password, "Undefined password"), Validate.notEmpty(clientId, "Undefined client ID"), Validate.notEmpty(clientPassword, "Undefined client password"), token, Validate.notNull(httpClient), Validate.notNull(mapper)); } private  SW360ClientConfig(URI baseURI, String authURL, String user, String password, String clientId,
                              String clientPassword, String token, HttpClient httpClient, ObjectMapper objectMapper); static SW360ClientConfig createConfig(String restURL, String authURL, String user,
                                                 String password, String clientId, String clientPassword,
                                                 String token, HttpClient httpClient, ObjectMapper mapper); String getRestURL(); URI getBaseURI(); String getAuthURL(); String getUser(); String getPassword(); String getClientId(); String getClientPassword(); String getToken(); HttpClient getHttpClient(); ObjectMapper getObjectMapper(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test(expected = NullPointerException.class) public void testNullRestUrlThrows() { SW360ClientConfig.createConfig(null, AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyRestUrlThrows() { SW360ClientConfig.createConfig("", AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testInvalidResUrlThrows() { SW360ClientConfig.createConfig("this is not a valid URL?!", AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullAuthUrlThrows() { SW360ClientConfig.createConfig(REST_URL, null, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyAuthUrlThrows() { SW360ClientConfig.createConfig(REST_URL, "", USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullUserThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, null, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyUserThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, "", PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullPasswordThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, null, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyPasswordThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, "", CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullClientThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, null, CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyClientThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, "", CLIENT_PASS, USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullClientPasswordThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, CLIENT_ID, null, USER_TOKEN, httpClient, mapper); }
@Test(expected = IllegalArgumentException.class) public void testEmptyClientPasswordThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, CLIENT_ID, "", USER_TOKEN, httpClient, mapper); }
@Test(expected = NullPointerException.class) public void testNullHttpClientThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, null, mapper); }
@Test(expected = NullPointerException.class) public void testNullObjectMapperThrows() { SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, null); }
@Test public void testCreateConfig() { SW360ClientConfig config = SW360ClientConfig.createConfig(REST_URL, AUTH_URL, USER, PASSWORD, CLIENT_ID, CLIENT_PASS, USER_TOKEN, httpClient, mapper); assertThat(config.getRestURL()).isEqualTo(REST_URL); assertThat(config.getAuthURL()).isEqualTo(AUTH_URL); assertThat(config.getUser()).isEqualTo(USER); assertThat(config.getPassword()).isEqualTo(PASSWORD); assertThat(config.getClientId()).isEqualTo(CLIENT_ID); assertThat(config.getClientPassword()).isEqualTo(CLIENT_PASS); assertThat(config.getToken()).isEqualTo(USER_TOKEN); assertThat(config.getHttpClient()).isEqualTo(httpClient); assertThat(config.getObjectMapper()).isEqualTo(mapper); assertThat(config.getBaseURI().toString()).isEqualTo(REST_URL); }