RoutingService { public boolean redirectRequestToStub(final WilmaHttpRequest request) { boolean redirect; ResponseDescriptorDTO responseDescriptorDTO = stubDescriptorEvaluator.findResponseDescriptor(stubDescriptors, request); if (responseDescriptorDTO == null) { responseDescriptorDTO = stubModeEvaluator.getResponseDescriptorForStubMode(request, operationMode); } redirect = responseDescriptorDTO != null; if (redirect) { request.addHeaderUpdate(WilmaHttpEntity.WILMA_LOGGER_ID, request.getWilmaMessageId()); saveInResponseDescriptorMap(request, responseDescriptorDTO); } return redirect; }  boolean redirectRequestToStub(final WilmaHttpRequest request); ResponseDescriptorDTO getResponseDescriptorDTOAndRemove(final String key); void setOperationMode(final OperationMode operationMode); Map<String, StubDescriptor> getStubDescriptors(); boolean isStubModeOn(); void performModification(final StubDescriptorModificationCommand command);  }
@Test public void testRedirectRequestToStubShouldReturnTrueWhenNewResponseDescriptorIsCreated() { requestBody = MSG_ID; given(request.getBody()).willReturn(requestBody); given(stubDescriptorEvaluator.findResponseDescriptor(stubDescriptors, request)).willReturn(responseDescriptorDTO); boolean actual = underTest.redirectRequestToStub(request); assertEquals(actual, true); }
@Test public void testRedirectRequestToStubShouldReturnFalseWhenResponseDescriptorIsNull() { given(request.getBody()).willReturn(requestBody); given(stubDescriptorEvaluator.findResponseDescriptor(stubDescriptors, request)).willReturn(null); boolean actual = underTest.redirectRequestToStub(request); assertEquals(actual, false); }
@Test public void testRedirectRequestToStubShouldCallStubModeEvaluatorGetResponseDescriptorForStubModeMethod() { Whitebox.setInternalState(underTest, "operationMode", OperationMode.STUB); given(request.getBody()).willReturn(requestBody); given(stubDescriptorEvaluator.findResponseDescriptor(stubDescriptors, request)).willReturn(null); underTest.redirectRequestToStub(request); verify(stubModeEvaluator).getResponseDescriptorForStubMode(request, OperationMode.STUB); }