UserCredentialVersion extends CredentialVersion { public void setPassword(final String password) { if (password != null) { super.setValue(password); } } UserCredentialVersion(final UserCredentialVersionData delegate);  UserCredentialVersion(final String name);  UserCredentialVersion(
    final UserCredentialValue userValue,
    final String name,
    final StringGenerationParameters generationParameters,
    final Encryptor encryptor
  ); @Override String getCredentialType(); @Override void rotate(); String getPassword(); void setPassword(final String password); String getUsername(); void setUsername(final String username); String getSalt(); void setSalt(final String salt); @Override StringGenerationParameters getGenerationParameters(); void setGenerationParameters(final StringGenerationParameters generationParameters); @Override boolean matchesGenerationParameters(final GenerationParameters generationParameters);  }
@Test public void setPassword_encryptedProvidedPasswordOnce_andSetsCorrectValuesOnDelegate() { when(encryptor.encrypt(eq(USER_PASSWORD))) .thenReturn(new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_PASSWORD, NONCE)); userCredentialData = new UserCredentialVersionData(CREDENTIAL_NAME); subject = new UserCredentialVersion(userCredentialData); subject.setEncryptor(encryptor); subject.setPassword(USER_PASSWORD); verify(encryptor, times(1)).encrypt(eq(USER_PASSWORD)); assertThat(userCredentialData.getEncryptionKeyUuid(), equalTo(ENCRYPTION_KEY_UUID)); assertThat(userCredentialData.getEncryptedValueData().getEncryptedValue(), equalTo(ENCRYPTED_PASSWORD)); assertThat(userCredentialData.getNonce(), equalTo(NONCE)); }