Skip to content

Commit

Permalink
when content type is omitted
Browse files Browse the repository at this point in the history
Signed-off-by: ac892247 <[email protected]>
  • Loading branch information
achmelo committed Oct 31, 2024
1 parent abf06aa commit 1bedafd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,20 @@ void givenLongApplicationName() {
//@formatter:on
}

@Test
void givenNoContentType() {
//@formatter:off
given()
.body(new TicketRequest(APPLICATION_NAME).toString().getBytes())
.cookie(COOKIE, jwt)
.noContentType()
.when()
.post(ZAAS_TICKET_URI)
.then()
.statusCode(is(SC_BAD_REQUEST));
//@formatter:on
}

@Test
void givenInvalidContentType() {
//@formatter:off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ public ResponseEntity<ApiMessageView> handleInternalException(Exception exceptio
.body(messageView);
}

@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<ApiMessageView> handleInternalException(IllegalArgumentException exception) {
log.debug("Client sent illegal arguments", exception);
ApiMessageView messageView = messageService.createMessage("org.zowe.apiml.common.badRequest").mapToView();
return ResponseEntity
.status(HttpStatus.BAD_REQUEST)
.contentType(MediaType.APPLICATION_JSON)
.body(messageView);
}

@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public ResponseEntity<ApiMessageView> handleUnsupportedMediaException(HttpMediaTypeNotSupportedException exception) {
log.debug("Requested media type is not supported", exception);
Expand Down

0 comments on commit 1bedafd

Please sign in to comment.