Skip to content

Commit

Permalink
test: fix expectInvalidResponseFormat with correct path param
Browse files Browse the repository at this point in the history
  • Loading branch information
takb committed Dec 10, 2024
1 parent 2d49044 commit 9b7530f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ public String getPostMapping(@RequestBody ExportApiRequest request) throws Missi
throw new MissingParameterException(ExportErrorCodes.MISSING_PARAMETER, "profile");
}

// Matches any response type that has not been defined
@PostMapping(value = "/{profile}/*")
@Operation(hidden = true)
public void getInvalidResponseType(@PathVariable String profile) throws StatusCodeException {
throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "The response format %s is not supported".formatted(profile));
}

// Functional request methods
@PostMapping(value = "/{profile}")
@Operation(
Expand Down Expand Up @@ -153,6 +146,12 @@ public TopoJsonExportResponse getTopoJsonExport(
return TopoJsonExportResponse.fromExportResult(result);
}

// Matches any response type that has not been defined
@PostMapping(value = "/{profile}/{responseType}")
@Operation(hidden = true)
public void getInvalidResponseType(@PathVariable String profile, @PathVariable String responseType) throws StatusCodeException {
throw new StatusCodeException(HttpServletResponse.SC_NOT_ACCEPTABLE, ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT, "The response format %s is not supported".formatted(responseType));
}

@ExceptionHandler(MissingServletRequestParameterException.class)
public ResponseEntity<Object> handleMissingParams(final MissingServletRequestParameterException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ void expectInvalidResponseFormat() {
.body(body.toString())
.when()
.post(getEndPointPath() + "/{profile}/blah")
.then()
.then().log().ifValidationFails()
.assertThat()
.body("error.code", Matchers.is(ExportErrorCodes.UNSUPPORTED_EXPORT_FORMAT))
.body("error.message", Matchers.is("The response format blah is not supported"))
.statusCode(406);
}

Expand Down

0 comments on commit 9b7530f

Please sign in to comment.