Make sure deprecated dependencies endpoint works with metadata v2.2

Closes gh-1115
This commit is contained in:
Stephane Nicoll 2020-08-12 11:21:30 +02:00
parent 6075c08a0c
commit 5d8c8539ac
2 changed files with 22 additions and 3 deletions

View File

@ -94,6 +94,11 @@ public class ProjectMetadataController extends AbstractMetadataController {
return serviceCapabilitiesFor(InitializrMetadataVersion.V2);
}
@RequestMapping(path = "/dependencies", produces = "application/vnd.initializr.v2.2+json")
public ResponseEntity<String> dependenciesV22(@RequestParam(required = false) String bootVersion) {
return dependenciesFor(InitializrMetadataVersion.V2_2, bootVersion);
}
@RequestMapping(path = "/dependencies", produces = { "application/vnd.initializr.v2.1+json", "application/json" })
public ResponseEntity<String> dependenciesV21(@RequestParam(required = false) String bootVersion) {
return dependenciesFor(InitializrMetadataVersion.V2_1, bootVersion);

View File

@ -88,10 +88,24 @@ class ProjectMetadataControllerCustomDefaultsIntegrationTests extends AbstractFu
}
@Test
void noBootVersion() throws JSONException {
ResponseEntity<String> response = execute("/dependencies", String.class, null, "application/json");
void dependenciesNoAcceptHeaderWithNoBootVersion() throws JSONException {
validateDependenciesMetadata("*/*", DEFAULT_METADATA_MEDIA_TYPE);
}
@Test
void dependenciesV21WithNoBootVersion() throws JSONException {
validateDependenciesMetadata("application/vnd.initializr.v2.1+json", DEFAULT_METADATA_MEDIA_TYPE);
}
@Test
void dependenciesV22WithNoBootVersion() throws JSONException {
validateDependenciesMetadata("application/vnd.initializr.v2.2+json", CURRENT_METADATA_MEDIA_TYPE);
}
private void validateDependenciesMetadata(String acceptHeader, MediaType expectedMediaType) throws JSONException {
ResponseEntity<String> response = execute("/dependencies", String.class, null, acceptHeader);
assertThat(response.getHeaders().getFirst(HttpHeaders.ETAG)).isNotNull();
validateContentType(response, DEFAULT_METADATA_MEDIA_TYPE);
validateContentType(response, expectedMediaType);
validateDependenciesOutput("2.1.4", response.getBody());
}