UserCredentialVersion extends CredentialVersion { @Override public StringGenerationParameters getGenerationParameters() { final String parameterJson = getEncryptor().decrypt(delegate.getEncryptedGenerationParameters()); if (parameterJson == null) { return null; } try { final StringGenerationParameters generationParameters = jsonObjectMapper .deserializeBackwardsCompatibleValue(parameterJson, StringGenerationParameters.class); final String password = this.password == null ? getPassword() : this.password; generationParameters.setLength(password.length()); return generationParameters; } catch (final IOException 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 getGenerationParameters_decryptsGenerationParameters() { final EncryptedValue parameterEncryption = new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_GENERATION_PARAMS, PARAMETERS_NONCE); final EncryptedValue passwordEncryption = new EncryptedValue(ENCRYPTION_KEY_UUID, ENCRYPTED_PASSWORD, NONCE); when(encryptor.decrypt(parameterEncryption)) .thenReturn(userGenerationParametersString); when(encryptor.decrypt(passwordEncryption)) .thenReturn(USER_PASSWORD); userCredentialData = new UserCredentialVersionData(); userCredentialData.setEncryptedValueData(passwordEncryption); userCredentialData.setEncryptedGenerationParameters(parameterEncryption); subject = new UserCredentialVersion(userCredentialData); subject.setEncryptor(encryptor); final StringGenerationParameters generationParameters = subject.getGenerationParameters(); assertThat(generationParameters, samePropertyValuesAs(stringGenerationParameters)); verify(encryptor, times(2)).decrypt(any()); }