@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));
}