Router implements ApplicationListener<ContextRefreshedEvent> { public void reroute(final WilmaHttpRequest request) { if (routingService.redirectRequestToStub(request)) { try { request.setUri(getURI()); } catch (URISyntaxException e) { logger.error(e.getMessage()); } } }  void reroute(final WilmaHttpRequest request); @Override void onApplicationEvent(final ContextRefreshedEvent event); Integer getInternalPort(); void setHost(final String host); void setPath(final String path);  }
@Test public void testRerouteShouldSetNewUri() throws URISyntaxException { uri = new URI("http: given(routingService.redirectRequestToStub(request)).willReturn(true); underTest.reroute(request); verify(request).setUri(uri); }
@Test public void testRerouteShouldNotSetNewUri() throws URISyntaxException { uri = new URI("http: given(routingService.redirectRequestToStub(request)).willReturn(false); underTest.reroute(request); verify(request, times(0)).setUri(uri); }