LocalhostRequestProcessor extends ProcessorBase { @Override public void process(final WilmaHttpEntity entity) throws ApplicationException { WilmaHttpRequest request = (WilmaHttpRequest) entity; boolean requestNeedsRerouting = localhostRequestChecker.checkIfRequestTargetsLocalhost(request); if (requestNeedsRerouting) { localhostRequestRouter.reroute(request); request.setRerouted(true); } }  @Override void process(final WilmaHttpEntity entity);  }
@Test public void testIfEnabledShouldNotRerouteNonLocalhostRequest() throws ApplicationException { underTest.setEnabled(true); given(localhostRequestChecker.checkIfRequestTargetsLocalhost(Mockito.any(WilmaHttpRequest.class))).willReturn(false); underTest.process(request); verify(localhostRequestRouter, never()).reroute(request); verify(request, never()).setRerouted(true); }
@Test public void testIfEnabledShouldRerouteLocalhostRequest() throws ApplicationException { underTest.setEnabled(true); given(localhostRequestChecker.checkIfRequestTargetsLocalhost(Mockito.any(WilmaHttpRequest.class))).willReturn(true); underTest.process(request); verify(localhostRequestRouter).reroute(request); verify(request).setRerouted(true); }