CredentialsConfig extends SimpleComponent<CredentialsConfig> implements PasswordsConfig<CredentialsConfig> { @Override public CredentialsConfig merge(final CredentialsConfig config) { return super.merge(config).toBuilder() .password((password == null || password.isEmpty()) ? config.password : password) .build(); }  @Override CredentialsConfig withoutPasswords(); @Override CredentialsConfig withEncryptedPasswords(final TextEncryptor encryptor); @Override CredentialsConfig withDecryptedPasswords(final TextEncryptor encryptor); @Override CredentialsConfig merge(final CredentialsConfig config);  }
@Test public void testMerge_missingValues() { Assert.assertEquals(new CredentialsConfig("user", "pass"), new CredentialsConfig(null, null).merge(decryptedValue)); }
@Test public void testMerge_providedValues() { Assert.assertEquals(new CredentialsConfig("new user", "new pass"), new CredentialsConfig("new user", "new pass").merge(decryptedValue)); }
@Test public void testMerge_emptyPassword() { Assert.assertEquals(new CredentialsConfig("new user", "pass"), new CredentialsConfig("new user", "").merge(decryptedValue)); }