### Question:
VariableValueJsonConverter implements AttributeConverter<VariableValue<?>, String> { @Override public VariableValue<?> convertToEntityAttribute(String dbData) { try { return objectMapper.readValue(dbData, VariableValue.class); } catch (IOException e) { throw new QueryException("Unable to deserialize variable.", e); } } VariableValueJsonConverter();  VariableValueJsonConverter(ObjectMapper objectMapper); @Override String convertToDatabaseColumn(VariableValue<?> variableValue); @Override VariableValue<?> convertToEntityAttribute(String dbData);  }### Answer:
@Test public void convertToEntityAttributeShouldConvertFromJson() throws Exception { given(objectMapper.readValue(JSON_REPRESENTATION, VariableValue.class)).willReturn(ENTITY_REPRESENTATION); VariableValue<?> convertedValue = converter.convertToEntityAttribute(JSON_REPRESENTATION); assertThat(convertedValue).isEqualTo(ENTITY_REPRESENTATION); }
@Test public void convertToEntityAttributeShouldThrowExceptionWhenExceptionOccursWhileReading() throws Exception { IOException ioException = new IOException(); given(objectMapper.readValue(JSON_REPRESENTATION, VariableValue.class)).willThrow(ioException); Throwable thrown = catchThrowable(() -> converter.convertToEntityAttribute(JSON_REPRESENTATION)); assertThat(thrown) .isInstanceOf(QueryException.class) .hasMessage("Unable to deserialize variable.") .hasCause(ioException); }