@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()); }
@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; }
SavePersonApiHandler extends AbstractDynamoDbHandler 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; } }
SavePersonApiHandler extends AbstractDynamoDbHandler 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; }  }
SavePersonApiHandler extends AbstractDynamoDbHandler 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); }
SavePersonApiHandler extends AbstractDynamoDbHandler 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);  }