use of org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter in project spring-boot by spring-projects.
the class HypermediaAutoConfigurationTests method customizationOfSupportedMediaTypesCanBeDisabled.
@Test
public void customizationOfSupportedMediaTypesCanBeDisabled() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context, "spring.hateoas.use-hal-as-default-json-media-type:false");
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes()).containsExactly(MediaTypes.HAL_JSON);
}
}
}
use of org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter in project spring-boot by spring-projects.
the class HypermediaAutoConfigurationTests method supportedMediaTypesOfTypeConstrainedConvertersIsCustomized.
@Test
public void supportedMediaTypesOfTypeConstrainedConvertersIsCustomized() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes()).contains(MediaType.APPLICATION_JSON, MediaTypes.HAL_JSON);
}
}
}
Aggregations