UserCredentialVersion extends CredentialVersion { public void setGenerationParameters(final StringGenerationParameters generationParameters) { final EncryptedValue encryptedParameters; try { final String generationParameterJson = generationParameters != null ? jsonObjectMapper.writeValueAsString(generationParameters) : null; if (generationParameterJson != null) { encryptedParameters = getEncryptor().encrypt(generationParameterJson); delegate.setEncryptedGenerationParameters(encryptedParameters); } } catch (final Exception e) { throw new RuntimeException(e); } } 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 setGenerationParameters_setsEncryptedGenerationParametersAndNonce() { when(encryptor.encrypt(eq(userGenerationParametersString))) .thenReturn(new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_GENERATION_PARAMS, PARAMETERS_NONCE)); userCredentialData = new UserCredentialVersionData(CREDENTIAL_NAME); subject = new UserCredentialVersion(userCredentialData); subject.setEncryptor(encryptor); subject.setGenerationParameters(stringGenerationParameters); verify(encryptor, times(1)).encrypt(eq(userGenerationParametersString)); assertThat(userCredentialData.getEncryptedGenerationParameters().getEncryptionKeyUuid(), equalTo(ENCRYPTION_KEY_UUID)); assertThat(userCredentialData.getEncryptedGenerationParameters().getEncryptedValue(), equalTo(ENCRYPTED_GENERATION_PARAMS)); assertThat(userCredentialData.getEncryptedGenerationParameters().getNonce(), equalTo(PARAMETERS_NONCE)); }