UserCredentialVersion extends CredentialVersion { public String getPassword() { this.password = (String) super.getValue(); return this.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 getPassword_returnsDecryptedPassword_andOnlyDecryptsOnce() { final EncryptedValue encryption = new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_PASSWORD, NONCE); when(encryptor.decrypt(encryption)) .thenReturn(USER_PASSWORD); final EncryptedValue encryptedValue = new EncryptedValue(); encryptedValue.setEncryptedValue(ENCRYPTED_PASSWORD); encryptedValue.setNonce(NONCE); encryptedValue.setEncryptionKeyUuid(ENCRYPTION_KEY_UUID); userCredentialData = new UserCredentialVersionData(); userCredentialData.setEncryptedValueData(encryptedValue); subject = new UserCredentialVersion(userCredentialData); subject.setEncryptor(encryptor); final String password = subject.getPassword(); assertThat(password, equalTo(USER_PASSWORD)); verify(encryptor, times(1)).decrypt(any()); }