Improve media type assertion

Instead of doing a strict equality between the expected media type
and the one received in the response, we use isCompatibleWith that
ensure that at least the expected capabilities are present.
This commit is contained in:
Stephane Nicoll
2014-12-08 18:07:27 +01:00
parent 627838cc44
commit 9e01b9af71

View File

@@ -133,14 +133,14 @@ class MainControllerIntegrationTests extends AbstractInitializrControllerIntegra
@Test
void metadataWithNoAcceptHeader() { // rest template sets application/json by default
ResponseEntity<String> response = getMetadata(null, '*/*')
assertEquals CURRENT_METADATA_MEDIA_TYPE, response.getHeaders().getContentType()
assertTrue response.headers.getContentType().isCompatibleWith(CURRENT_METADATA_MEDIA_TYPE)
validateCurrentMetadata(new JSONObject(response.body))
}
@Test
void metadataWithCurrentAcceptHeader() {
ResponseEntity<String> response = getMetadata(null, 'application/vnd.initializr.v2+json')
assertEquals CURRENT_METADATA_MEDIA_TYPE, response.getHeaders().getContentType()
assertTrue response.headers.getContentType().isCompatibleWith(CURRENT_METADATA_MEDIA_TYPE)
validateCurrentMetadata(new JSONObject(response.body))
}