WilmaHttpRequestCloner { public WilmaHttpRequest cloneRequest(final WilmaHttpRequest request) { WilmaHttpRequest result = new WilmaHttpRequest(); result.setRequestLine(request.getRequestLine()); result.setUri(request.getUri()); result.setBody(request.getBody()); result.setWilmaMessageId(request.getWilmaMessageId()); copyHeaders(request, result); return result; }  WilmaHttpRequest cloneRequest(final WilmaHttpRequest request);  }
@Test public void testCloneRequestShouldReturnRequestBody() { request.setBody("body"); WilmaHttpRequest actual = underTest.cloneRequest(request); assertEquals(actual.getBody(), request.getBody()); }
@Test public void testCloneRequestShouldCloneRequestLine() { request.setRequestLine("request-line"); WilmaHttpRequest actual = underTest.cloneRequest(request); assertEquals(actual.getRequestLine(), request.getRequestLine()); }
@Test public void testCloneRequestShouldCloneRequestURI() throws URISyntaxException { request.setUri(new URI("blabla")); WilmaHttpRequest actual = underTest.cloneRequest(request); assertEquals(actual.getUri(), request.getUri()); }
@Test public void testCloneRequestShouldReturnRequestHeaders() { request.addHeader(CONTENT_TYPE_HEADER, XML_CONTENT); request.addHeader(CONTENT_ENCODING_HEADER, GZIP_CONTENT); WilmaHttpRequest actual = underTest.cloneRequest(request); assertEquals(actual.getHeader(CONTENT_TYPE_HEADER), XML_CONTENT); assertEquals(actual.getHeader(CONTENT_ENCODING_HEADER), GZIP_CONTENT); }
@Test public void testCloneRequestShouldReturnRequestHeaderUpdates() { request.addHeaderUpdate(CONTENT_TYPE_HEADER, XML_CONTENT); request.addHeaderUpdate(CONTENT_ENCODING_HEADER, GZIP_CONTENT); WilmaHttpRequest actual = underTest.cloneRequest(request); assertEquals(actual.getHeaderUpdateValue(CONTENT_TYPE_HEADER), XML_CONTENT); assertEquals(actual.getHeaderUpdateValue(CONTENT_ENCODING_HEADER), GZIP_CONTENT); }
@Test public void testCloneRequestShouldReturnRequestHeaderRemovals() { request.addHeaderRemove(CONTENT_TYPE_HEADER); request.addHeaderRemove(CONTENT_ENCODING_HEADER); WilmaHttpRequest actual = underTest.cloneRequest(request); assertTrue(actual.getHeaderChanges().entrySet().size() == 2); }