@Test
  public void shouldPutContentIntoPayload() throws Exception {
    HttpRequest amazonRequest = new HttpRequest(HttpMethodName.POST);
    amazonRequest.setEndpoint(new URI("https://endpoint/"));
    amazonRequest.setContent(new ByteArrayInputStream("PAYLOAD".getBytes()));

    HTTPRequest googleRequest =
        new AmazonHttpRequestToGoogleHttpRequestAdaptor()
            .convert(HttpClient.convertToRequest(amazonRequest));
    assertEquals("https://endpoint/", googleRequest.getURL().toString());
    assertEquals("PAYLOAD", new String(googleRequest.getPayload()));
  }
  @Test
  public void shouldIncludeParametersInRequestBodyForPostRequestIfNoContentSupplied()
      throws Exception {
    HttpRequest amazonRequest = new HttpRequest(HttpMethodName.POST);
    amazonRequest.setEndpoint(new URI("https://endpoint/"));
    amazonRequest.addParameter("key", "value");

    HTTPRequest googleRequest =
        new AmazonHttpRequestToGoogleHttpRequestAdaptor()
            .convert(HttpClient.convertToRequest(amazonRequest));
    assertEquals("https://endpoint/", googleRequest.getURL().toString());
    assertEquals("key=value", new String(googleRequest.getPayload()));
  }
  @Test
  public void shouldPutParamatersInQueryStringWhenContentAlsoSupplied() throws Exception {
    HttpRequest amazonRequest = new HttpRequest(HttpMethodName.POST);
    amazonRequest.setEndpoint(new URI("https://endpoint/"));
    amazonRequest.addParameter("key", "value");
    amazonRequest.setContent(new ByteArrayInputStream("PAYLOAD".getBytes()));

    HTTPRequest googleRequest =
        new AmazonHttpRequestToGoogleHttpRequestAdaptor()
            .convert(HttpClient.convertToRequest(amazonRequest));
    assertEquals("https://endpoint/?key=value", googleRequest.getURL().toString());
    assertEquals("PAYLOAD", new String(googleRequest.getPayload()));
  }
 private static Request<?> request(HttpMethodName method) throws URISyntaxException {
   HttpRequest request = new HttpRequest(method);
   request.setEndpoint(new URI("http://endpoint"));
   return HttpClient.convertToRequest(request);
 }