JsonCredentialVersion extends CredentialVersion { public void setValue(final JsonNode value) { if (value == null) { throw new ParameterizedValidationException(ErrorMessages.MISSING_VALUE); } try { final String serializedString = objectMapper.writeValueAsString(value); super.setValue(serializedString); } catch (final JsonProcessingException e) { throw new RuntimeException(e); } } JsonCredentialVersion(final JsonCredentialVersionData delegate);  JsonCredentialVersion(final String name);  JsonCredentialVersion(final JsonCredentialValue jsonValue, final String name, final Encryptor encryptor); @Override String getCredentialType(); @Override void rotate(); @Override JsonNode getValue(); void setValue(final JsonNode value); @Override boolean matchesGenerationParameters(final GenerationParameters generationParameters); @Override GenerationParameters getGenerationParameters();  }
@Test public void setValue_setsEncryptedValueAndNonce() { subject.setValue(value); assertThat(jsonCredentialData.getEncryptedValueData().getEncryptedValue(), notNullValue()); assertThat(jsonCredentialData.getNonce(), notNullValue()); }
@Test public void setValue_whenValueIsNull_throwsException() { try { subject.setValue((JsonNode) null); fail("should throw"); } catch (final ParameterizedValidationException e) { assertThat(e.getMessage(), equalTo(ErrorMessages.MISSING_VALUE)); } }