use of org.craftercms.commons.jackson.ObjectIdDeserializer in project profile by craftercms.
the class AbstractRestHandlerTestBase method createResponseWriter.
protected HttpMessageConvertingResponseWriter createResponseWriter() {
ContentNegotiationManagerFactoryBean factoryBean = new ContentNegotiationManagerFactoryBean();
factoryBean.afterPropertiesSet();
ContentNegotiationManager contentNegotiationManager = factoryBean.getObject();
List<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
List<JsonSerializer<?>> serializers = new ArrayList<>();
serializers.add(new ObjectIdSerializer());
Map<Class<?>, JsonDeserializer<?>> deserializers = new HashMap<>();
deserializers.put(ObjectId.class, new ObjectIdDeserializer());
CustomSerializationObjectMapper objectMapper = new CustomSerializationObjectMapper();
objectMapper.setSerializers(serializers);
objectMapper.setDeserializers(deserializers);
objectMapper.init();
MappingJackson2HttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter();
jsonMessageConverter.setObjectMapper(objectMapper);
messageConverters.add(jsonMessageConverter);
return new HttpMessageConvertingResponseWriter(contentNegotiationManager, messageConverters);
}
Aggregations