use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project tutorials by eugenp.
the class OAuth2IntegrationTestSupport method getOAuth2RestTemplate.
protected OAuth2RestTemplate getOAuth2RestTemplate(final ClientCredentialsResourceDetails resourceDetails) {
DefaultOAuth2ClientContext clientContext = new DefaultOAuth2ClientContext();
OAuth2RestTemplate restTemplate = new OAuth2RestTemplate(resourceDetails, clientContext);
restTemplate.setMessageConverters(singletonList(new MappingJackson2HttpMessageConverter()));
return restTemplate;
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project tutorials by eugenp.
the class RestTemplateBasicLiveTest method givenFooService_whenPatchExistingEntity_thenItIsUpdated.
// PATCH
@Test
public void givenFooService_whenPatchExistingEntity_thenItIsUpdated() {
final HttpHeaders headers = prepareBasicAuthHeaders();
final HttpEntity<Foo> request = new HttpEntity<>(new Foo("bar"), headers);
// Create Resource
final ResponseEntity<Foo> createResponse = restTemplate.exchange(fooResourceUrl, HttpMethod.POST, request, Foo.class);
// Update Resource
final Foo updatedResource = new Foo("newName");
updatedResource.setId(createResponse.getBody().getId());
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody().getId();
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
final ClientHttpRequestFactory requestFactory = getSimpleClientHttpRequestFactory();
final RestTemplate template = new RestTemplate(requestFactory);
template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter()));
template.patchForObject(resourceUrl, requestUpdate, Void.class);
// Check that Resource was updated
final ResponseEntity<Foo> updateResponse = restTemplate.exchange(resourceUrl, HttpMethod.GET, new HttpEntity<>(headers), Foo.class);
final Foo foo = updateResponse.getBody();
assertThat(foo.getName(), is(updatedResource.getName()));
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project tutorials by eugenp.
the class WebConfig method configureMessageConverters.
//
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> messageConverters) {
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.indentOutput(true).dateFormat(new SimpleDateFormat("dd-MM-yyyy hh:mm"));
messageConverters.add(new MappingJackson2HttpMessageConverter(builder.build()));
messageConverters.add(new MappingJackson2XmlHttpMessageConverter(builder.createXmlMapper(true).build()));
messageConverters.add(createXmlHttpMessageConverter());
// messageConverters.add(new MappingJackson2HttpMessageConverter());
messageConverters.add(new ProtobufHttpMessageConverter());
messageConverters.add(new KryoHttpMessageConverter());
messageConverters.add(new StringHttpMessageConverter());
super.configureMessageConverters(messageConverters);
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project tutorials by eugenp.
the class WebConfig method configureMessageConverters.
// beans
@Override
public void configureMessageConverters(final List<HttpMessageConverter<?>> converters) {
super.configureMessageConverters(converters);
converters.add(new MappingJackson2HttpMessageConverter());
}
use of org.springframework.http.converter.json.MappingJackson2HttpMessageConverter in project ma-core-public by infiniteautomation.
the class MangoRestSpringConfiguration method configureMessageConverters.
/**
* Configure the Message Converters for the API for now only JSON
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
converters.add(new ResourceHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter(getObjectMapper()));
converters.add(new CsvMessageConverter());
converters.add(new CsvRowMessageConverter());
converters.add(new CsvQueryArrayStreamMessageConverter());
converters.add(new CsvDataPageQueryStreamMessageConverter());
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new HtmlHttpMessageConverter());
converters.add(new SerotoninJsonMessageConverter());
converters.add(new ExceptionCsvMessageConverter());
// Now is a good time to register our Sero Json Converter
Common.JSON_CONTEXT.addConverter(new AbstractRestModelConverter(), AbstractRestModel.class);
}
Aggregations