ComponentSourceConverter implements AttributeConverter<ComponentSource, String> { @Override public ComponentSource convertToEntityAttribute(final String source) { try { return mapper.readValue(source, ComponentSource.class); } catch (final IOException e) { log.error("Unable to parse component source - {}", e.getMessage(), e); throw new FabricManagerException(e); } } ComponentSourceConverter();  ComponentSourceConverter(final ObjectMapper mapper); @Override String convertToDatabaseColumn(final ComponentSource componentSource); @Override ComponentSource convertToEntityAttribute(final String source);  }
@Test public void shouldConvertStringToEntityAttribute() throws JsonProcessingException { final ComponentSourceConverter converter = new ComponentSourceConverter(); final ComponentSource componentSource = converter.convertToEntityAttribute(sourceString); assertEquals(new ObjectMapper().writeValueAsString(componentSource), sourceString); }