Skip to content

Commit

Permalink
fixed java8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Romanens committed Dec 1, 2023
1 parent 3e336c4 commit 36318b2
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,28 +234,32 @@ public void validate_inputKO_schemaInClasspath_shouldThrowValidationException()
@Test
public void validate_inputOK_schemaInString_shouldValidate() {
ValidationInboundAPIGatewayV2HTTPEventHandler handler = new ValidationInboundAPIGatewayV2HTTPEventHandler();
APIGatewayV2HTTPEvent event = new APIGatewayV2HTTPEvent();
event.setBody("{" +
" \"id\": 1," +
" \"name\": \"Lampshade\"," +
" \"price\": 42" +
"}");
APIGatewayV2HTTPResponse response = handler.handleRequest(event, context);
assertThat(response.getBody()).isEqualTo("valid-test");
assertThat(response.getStatusCode()).isEqualTo(200);
APIGatewayV2HTTPEvent event = new APIGatewayV2HTTPEvent();
event.setBody("{" +
" \"id\": 1," +
" \"name\": \"Lampshade\"," +
" \"price\": 42" +
"}");

APIGatewayV2HTTPResponse response = handler.handleRequest(event, context);
assertThat(response.getBody()).isEqualTo("valid-test");
assertThat(response.getStatusCode()).isEqualTo(200);
}


@Test
public void validate_inputKO_schemaInString_shouldThrowValidationException() {
ValidationInboundAPIGatewayV2HTTPEventHandler handler = new ValidationInboundAPIGatewayV2HTTPEventHandler();

Map<String, String> headers = new HashMap<>();
headers.put("header1", "value1");

APIGatewayV2HTTPEvent event = new APIGatewayV2HTTPEvent();
event.setBody("{" +
" \"id\": 1," +
" \"name\": \"Lampshade\"" +
"}");
event.setHeaders(Map.of("header1", "value1"));
event.setHeaders(headers);

APIGatewayV2HTTPResponse response = handler.handleRequest(event, context);
assertThat(response.getBody()).isNotBlank();
Expand Down

0 comments on commit 36318b2

Please sign in to comment.