### Question:
SavePersonApiHandler extends AbstractDynamoDbHandler<Person> implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> { @Override public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent req, Context ctx) { try { var objectMapper = getObjectMapper(); var person = objectMapper.readValue(req.getBody(), Person.class); getDynamoDbMapper().save(person); return apiGatewayProxyResponseEvent(CREATED_STATUS_CODE, person); } catch (IOException ioException) { LOG.error("unable to parse body", ioException); return apiGatewayProxyResponseEvent(BAD_REQUEST_STATUS_CODE, null); } }  @Override APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent req, Context ctx);  }### Answer:
@Test public void handleRequestSavePersonSuccessful() throws JsonProcessingException { var person = newPerson(); var body = objectMapper.writeValueAsString(person); var request = apiGatewayProxyRequestEvent(body); var ctx = mock(Context.class); var apiGatewayProxyResponseEvent = this.savePersonApiHandler.handleRequest(request, ctx); verify(dynamoDbMapper, times(1)).save(person); Assert.assertNotNull(apiGatewayProxyResponseEvent); Assert.assertEquals(Integer.valueOf(201), apiGatewayProxyResponseEvent.getStatusCode()); }
@Test public void handleRequestSavePersonException() { var request = apiGatewayProxyRequestEvent("invalid sample request"); var ctx = mock(Context.class); var apiGatewayProxyResponseEvent = this.savePersonApiHandler.handleRequest(request, ctx); Assert.assertNotNull(apiGatewayProxyResponseEvent); Assert.assertEquals(Integer.valueOf(400), apiGatewayProxyResponseEvent.getStatusCode()); }