HttpServletRequestTransformer { public WilmaHttpRequest transformToWilmaHttpRequest(final String wilmaLoggerId, final HttpServletRequest request, final ResponseDescriptorDTO responseDescriptorDTO) { WilmaHttpRequest wilmaRequest = new WilmaHttpRequest(); copyServletHeadersIntoWilmaRequest(request, wilmaRequest); copyUnCompressedBodyIntoWilmaRequest(responseDescriptorDTO, wilmaRequest); wilmaRequest.setWilmaMessageId(wilmaLoggerId); return requestCloner.cloneRequest(wilmaRequest); }  WilmaHttpRequest transformToWilmaHttpRequest(final String wilmaLoggerId, final HttpServletRequest request, final ResponseDescriptorDTO responseDescriptorDTO);  }
@Test public void testTransformToWilmaHttpRequestShouldGetHeadersToCopyIntoResultWhenNoHeader() { given(request.getHeaderNames()).willReturn(enumeration); underTest.transformToWilmaHttpRequest(WILMA_LOGGER_ID, request, responseDescriptorDTO); verify(request, Mockito.times(0)).getHeader(Matchers.anyString()); }
@Test public void testTransformToWilmaHttpRequestShouldGetHeadersToCopyIntoResultWhenOneHeader() { headers.add("Content-type"); headers.add("Any-other-header"); given(request.getHeaderNames()).willReturn(enumeration); underTest.transformToWilmaHttpRequest(WILMA_LOGGER_ID, request, responseDescriptorDTO); verify(request, Mockito.times(2)).getHeader(Matchers.anyString()); }
@Test public void testTransformToWilmaHttpRequestShouldCopyUnCompressedBodyFromResponseDescriptorDTOIntoResult() { given(request.getHeaderNames()).willReturn(enumeration); given(responseDescriptorDTO.getRequestBody()).willReturn(REQUEST_BODY); WilmaHttpRequest actual = underTest.transformToWilmaHttpRequest(WILMA_LOGGER_ID, request, responseDescriptorDTO); Assert.assertEquals(actual, wilmaRequest); }