@Override public void forwardTo(String uri) { use(page()).forwardTo(uri); }
@Test public void shouldUseValidationVersionOfPageResult() throws Exception { exception.expect(ValidationException.class); when(result.use(PageResult.class)).thenReturn(new MockedPage()); factory.instanceFor(PageResult.class, errors).forwardTo("any uri"); }
@Override public void forward() throws IllegalStateException { String referer = getReferer(); try { ControllerMethod method = router.parse(referer, HttpMethod.GET, request); executeMethod(method, result.use(logic()).forwardTo(method.getController().getType())); } catch (ControllerNotFoundException | MethodNotAllowedException e) { logger.warn("Could not find or doesn't allowed to get controller method", e); result.use(page()).forwardTo(referer); } }
@Test public void shouldThrowExceptionOnlyAtTheEndOfValidationCall() throws Exception { when(result.use(LogicResult.class)).thenReturn(new MockedLogic()); when(result.use(PageResult.class)).thenReturn(new MockedPage()); factory.instanceFor(LogicResult.class, errors); factory.instanceFor(LogicResult.class, errors).forwardTo(RandomComponent.class); factory.instanceFor(PageResult.class, errors); factory.instanceFor(PageResult.class, errors).of(RandomComponent.class); }
@Test public void shouldNotThrowNullPointersOnLogicResult() throws Exception { result.use(logic()).forwardTo(AController.class).aMethod(); result.use(logic()).redirectTo(AController.class).aMethod(); }