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