@Test public void whenRefererMatchesAControllerShouldRedirectToIt() throws Exception { LogicResult logic = mock(LogicResult.class); RefererController controller = mock(RefererController.class); Method index = RefererController.class.getMethod("index"); ResourceMethod method = DefaultResourceMethod.instanceFor(RefererController.class, index); when(request.getHeader("Referer")).thenReturn("http: when(request.getContextPath()).thenReturn("/vraptor"); when(router.parse("/no-controller", HttpMethod.GET, request)).thenReturn(method); doReturn(logic).when(result).use(logic()); when(logic.redirectTo(RefererController.class)).thenReturn(controller); refererResult.redirect(); verify(logic).redirectTo(RefererController.class); verify(controller).index(); }
public void redirect() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).redirectTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).redirectTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).redirectTo(referer); } }
DefaultRefererResult implements RefererResult { public void redirect() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).redirectTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).redirectTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).redirectTo(referer); } } }
DefaultRefererResult implements RefererResult { public void redirect() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).redirectTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).redirectTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).redirectTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); }
DefaultRefererResult implements RefererResult { public void redirect() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).redirectTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).redirectTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).redirectTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); void forward(); void redirect(); }
DefaultRefererResult implements RefererResult { public void redirect() throws IllegalStateException { String referer = getReferer(); try { ResourceMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).redirectTo(method.getResource().getType())); } catch (ResourceNotFoundException e) { result.use(page()).redirectTo(referer); } catch (MethodNotAllowedException e) { result.use(page()).redirectTo(referer); } } DefaultRefererResult(Result result, MutableRequest request, Router router,
				ParametersProvider provider, Localization localization); void forward(); void redirect();  }