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