ComponentSourceConverter implements AttributeConverter<ComponentSource, String> { @Override public String convertToDatabaseColumn(final ComponentSource componentSource) { try { return mapper.writeValueAsString(componentSource); } catch (final JsonProcessingException 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 shouldConvertComponentSourceToDatabaseColumn() { final ComponentSourceConverter converter = new ComponentSourceConverter(); final String json = converter.convertToDatabaseColumn(source); assertEquals(json, sourceString); }