@Test public void testUpdateRequestShouldCallBrowsermobRequestsMethods() throws URISyntaxException { // GIVEN URI uri = new URI("MOCK"); given(browserMobHttpRequest.getMethod()).willReturn(requestBase); given(wilmaHttpRequest.getUri()).willReturn(uri); String mockID = "WILMA-LOG-MOCK-ID"; given(wilmaHttpRequest.getWilmaMessageId()).willReturn(mockID); // WHEN underTest.updateRequest(browserMobHttpRequest, wilmaHttpRequest); // THEN verify(requestBase).setURI(uri); }
@Test public void testUpdateRequestShouldUpdateBodyPart() throws URISyntaxException { // GIVEN URI uri = new URI("MOCK"); given(browserMobHttpRequest.getMethod()).willReturn(enclosingRequest); String mockID = "WILMA-LOG-MOCK-ID"; given(wilmaHttpRequest.getWilmaMessageId()).willReturn(mockID); given(wilmaHttpRequest.getNewBody()).willReturn("NEW BODY".getBytes()); given(wilmaHttpRequest.getUri()).willReturn(uri); // WHEN underTest.updateRequest(browserMobHttpRequest, wilmaHttpRequest); // THEN verify(enclosingRequest).setEntity((HttpEntity) Matchers.anyObject()); }
@Test public void testUpdateRequestShouldUpdateHeadersAddPart() throws URISyntaxException { // GIVEN URI uri = new URI("MOCK"); given(browserMobHttpRequest.getMethod()).willReturn(requestBase); given(wilmaHttpRequest.getUri()).willReturn(uri); String mockID = "WILMA-LOG-MOCK-ID"; Map<String, HttpHeaderChange> headerChanges = new HashMap<>(); HttpHeaderToBeUpdated headerToBeUpdated = new HttpHeaderToBeUpdated("B"); headerChanges.put("A", headerToBeUpdated); given(wilmaHttpRequest.getHeaderChanges()).willReturn(headerChanges); given(wilmaHttpRequest.getWilmaMessageId()).willReturn(mockID); // WHEN underTest.updateRequest(browserMobHttpRequest, wilmaHttpRequest); // THEN verify(requestBase).addHeader("A", "B"); }