@Test public void correctRequestTransformFromESToGWWithEmptyBody() { StatusLine mockStatusLine = mock(StatusLine.class); when(mockESResponse.getStatusLine()).thenReturn(mockStatusLine); when(mockStatusLine.getStatusCode()).thenReturn(TestConstants.STATUS_CODE_OK); when(mockESResponse.getEntity()).thenReturn(null); APIGatewayProxyResponseEvent apiGWResponse = HTTPTransformer.esResponseToAPIGatewayResponse(mockESResponse); assertEquals(TestConstants.STATUS_CODE_OK, apiGWResponse.getStatusCode().intValue()); assertNull(apiGWResponse.getBody()); }
public static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse) throws InternalErrorException { int statusCode = esResponse.getStatusLine().getStatusCode(); HttpEntity entity = esResponse.getEntity(); if (entity == null) { return new APIGatewayProxyResponseEvent().withStatusCode(statusCode); } String responseBody = transformHttpEntityToString(entity); return new APIGatewayProxyResponseEvent() .withStatusCode(statusCode) .withBody(responseBody); }
HTTPTransformer { public static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse) throws InternalErrorException { int statusCode = esResponse.getStatusLine().getStatusCode(); HttpEntity entity = esResponse.getEntity(); if (entity == null) { return new APIGatewayProxyResponseEvent().withStatusCode(statusCode); } String responseBody = transformHttpEntityToString(entity); return new APIGatewayProxyResponseEvent() .withStatusCode(statusCode) .withBody(responseBody); } }
HTTPTransformer { public static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse) throws InternalErrorException { int statusCode = esResponse.getStatusLine().getStatusCode(); HttpEntity entity = esResponse.getEntity(); if (entity == null) { return new APIGatewayProxyResponseEvent().withStatusCode(statusCode); } String responseBody = transformHttpEntityToString(entity); return new APIGatewayProxyResponseEvent() .withStatusCode(statusCode) .withBody(responseBody); }  }
HTTPTransformer { public static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse) throws InternalErrorException { int statusCode = esResponse.getStatusLine().getStatusCode(); HttpEntity entity = esResponse.getEntity(); if (entity == null) { return new APIGatewayProxyResponseEvent().withStatusCode(statusCode); } String responseBody = transformHttpEntityToString(entity); return new APIGatewayProxyResponseEvent() .withStatusCode(statusCode) .withBody(responseBody); }  static Request apiGatewayRequestToESRequest(@NonNull final APIGatewayProxyRequestEvent requestEvent); static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse); static String transformHttpEntityToString(final HttpEntity entity); }
HTTPTransformer { public static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse) throws InternalErrorException { int statusCode = esResponse.getStatusLine().getStatusCode(); HttpEntity entity = esResponse.getEntity(); if (entity == null) { return new APIGatewayProxyResponseEvent().withStatusCode(statusCode); } String responseBody = transformHttpEntityToString(entity); return new APIGatewayProxyResponseEvent() .withStatusCode(statusCode) .withBody(responseBody); }  static Request apiGatewayRequestToESRequest(@NonNull final APIGatewayProxyRequestEvent requestEvent); static APIGatewayProxyResponseEvent esResponseToAPIGatewayResponse(@NonNull final Response esResponse); static String transformHttpEntityToString(final HttpEntity entity);  }