#1521 - Allow HATEOAS bootstrap without any default media type enabled.

@EnableHypermediaSupport(types = {}) was not working anymore as the Comparator implementation working with the selected types rejected an empty list. We now do not reject that anymore to enable applications that solely work with third party media types.
This commit is contained in:
Oliver Drotbohm
2021-04-19 16:51:05 +02:00
parent 91e17f1196
commit d7ac32a99d
2 changed files with 13 additions and 7 deletions

View File

@@ -40,7 +40,7 @@ class HypermediaMappingInformationComparator implements Comparator<HypermediaMap
*/
HypermediaMappingInformationComparator(List<MediaType> mediaTypes) {
Assert.notEmpty(mediaTypes, "MediaTypes must not be empty!");
Assert.notNull(mediaTypes, "MediaTypes must not be null!");
this.mediaTypes = mediaTypes;
}

View File

@@ -351,13 +351,7 @@ class EnableHypermediaSupportIntegrationTest {
* RepresentationModel -> uber, application/json, application/*+json
*
* hal-forms, uber, application/json, application/*+json
*
*
*
*
*
*/
@Test
void ordersMediaTypeIntegrationBasedOnConfiguration() {
@@ -370,6 +364,14 @@ class EnableHypermediaSupportIntegrationTest {
});
}
@Test // #1521
void bootstrapsWithOutDefaultMediaTypeEnabled() {
assertThatNoException().isThrownBy(() -> {
withServletContext(NoDefaultMediaTypes.class, context -> {});
});
}
private static void assertEntityLinksSetUp(ApplicationContext context) {
assertThat(context.getBeansOfType(EntityLinks.class).values()) //
@@ -588,4 +590,8 @@ class EnableHypermediaSupportIntegrationTest {
static class MediaTypeOrdering {
}
@Configuration
@EnableHypermediaSupport(type = {})
static class NoDefaultMediaTypes {}
}