Skip to content

Commit

Permalink
Make sure deprecated dependencies endpoint works with metadata v2.2
Browse files Browse the repository at this point in the history
Closes gh-1115
  • Loading branch information
snicoll committed Aug 12, 2020
1 parent 6075c08 commit 5d8c853
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public ResponseEntity<String> serviceCapabilitiesV2() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,24 @@ void metadataClientEndpoint() {
}

@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());
}

Expand Down

0 comments on commit 5d8c853

Please sign in to comment.