ControlPointServerConfig extends SimpleComponent<ControlPointServerConfig> implements PasswordsConfig<ControlPointServerConfig> { public ControlPointServerDetails toServerDetails() { final ControlPointServerDetails.ControlPointServerDetailsBuilder builder = ControlPointServerDetails.builder() .protocol(protocol.toLowerCase()) .host(host) .port(port) .username(credentials == null ? null : credentials.getUsername()) .password(credentials == null ? null : credentials.getPassword()); if (basePath != null) builder.basePath(basePath); return builder.build(); }  @Override void basicValidate(final String component); @Override ControlPointServerConfig withoutPasswords(); @Override ControlPointServerConfig withEncryptedPasswords(final TextEncryptor encryptor); @Override ControlPointServerConfig withDecryptedPasswords(final TextEncryptor encryptor); ControlPointServerDetails toServerDetails();  }
@Test public void testToServerDetails() throws ConfigException { final ControlPointServerDetails serverDetails = validConfig.toServerDetails(); Assert.assertEquals("should set lowercase protocol", "http", serverDetails.getProtocol()); Assert.assertEquals("should set host", "example.com", serverDetails.getHost()); Assert.assertEquals("should set port", 123, serverDetails.getPort()); Assert.assertEquals("should set username", "user", serverDetails.getUsername()); Assert.assertEquals("should set password", "pass", serverDetails.getPassword()); Assert.assertEquals("should set base path", "base/path", serverDetails.getBasePath()); }
@Test public void testToServerDetails_missingBasePath() throws ConfigException { final ControlPointServerDetails serverDetails = validConfig.toBuilder().basePath(null).build().toServerDetails(); Assert.assertEquals("should not set base path", "/WebApi/api", serverDetails.getBasePath()); }