@Test public void cannotRedirectWhenLogicMethodIsAnnotatedWithAnyHttpMethodButGet() throws Exception { try { logicResult.redirectTo(MyComponent.class).annotated(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { verify(response, never()).sendRedirect(any(String.class)); } }
public <T> T redirectTo(final Class<T> type) { logger.debug("redirecting to class {}", type.getSimpleName()); return proxifier.proxify(type, new MethodInvocation<T>() { public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { if (!acceptsHttpGet(method)) { throw new IllegalArgumentException( "Your logic method must accept HTTP GET method if you want to redirect to it"); } try { String path = request.getContextPath(); String url = router.urlFor(type, method, args); includeParametersInFlash(type, method, args); path = path + url; logger.debug("redirecting to {}", path); response.sendRedirect(path); return null; } catch (IOException e) { throw new ProxyInvocationException(e); } } }); }
DefaultLogicResult implements LogicResult { public <T> T redirectTo(final Class<T> type) { logger.debug("redirecting to class {}", type.getSimpleName()); return proxifier.proxify(type, new MethodInvocation<T>() { public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { if (!acceptsHttpGet(method)) { throw new IllegalArgumentException( "Your logic method must accept HTTP GET method if you want to redirect to it"); } try { String path = request.getContextPath(); String url = router.urlFor(type, method, args); includeParametersInFlash(type, method, args); path = path + url; logger.debug("redirecting to {}", path); response.sendRedirect(path); return null; } catch (IOException e) { throw new ProxyInvocationException(e); } } }); } }
DefaultLogicResult implements LogicResult { public <T> T redirectTo(final Class<T> type) { logger.debug("redirecting to class {}", type.getSimpleName()); return proxifier.proxify(type, new MethodInvocation<T>() { public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { if (!acceptsHttpGet(method)) { throw new IllegalArgumentException( "Your logic method must accept HTTP GET method if you want to redirect to it"); } try { String path = request.getContextPath(); String url = router.urlFor(type, method, args); includeParametersInFlash(type, method, args); path = path + url; logger.debug("redirecting to {}", path); response.sendRedirect(path); return null; } catch (IOException e) { throw new ProxyInvocationException(e); } } }); } @Inject  DefaultLogicResult(Proxifier proxifier, Router router, MutableRequest request, MutableResponse response,
			Container container, PathResolver resolver, TypeNameExtractor extractor, FlashScope flash, MethodInfo methodInfo); }
DefaultLogicResult implements LogicResult { public <T> T redirectTo(final Class<T> type) { logger.debug("redirecting to class {}", type.getSimpleName()); return proxifier.proxify(type, new MethodInvocation<T>() { public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { if (!acceptsHttpGet(method)) { throw new IllegalArgumentException( "Your logic method must accept HTTP GET method if you want to redirect to it"); } try { String path = request.getContextPath(); String url = router.urlFor(type, method, args); includeParametersInFlash(type, method, args); path = path + url; logger.debug("redirecting to {}", path); response.sendRedirect(path); return null; } catch (IOException e) { throw new ProxyInvocationException(e); } } }); } @Inject  DefaultLogicResult(Proxifier proxifier, Router router, MutableRequest request, MutableResponse response,
			Container container, PathResolver resolver, TypeNameExtractor extractor, FlashScope flash, MethodInfo methodInfo); T forwardTo(final Class<T> type); T redirectTo(final Class<T> type); }
DefaultLogicResult implements LogicResult { public <T> T redirectTo(final Class<T> type) { logger.debug("redirecting to class {}", type.getSimpleName()); return proxifier.proxify(type, new MethodInvocation<T>() { public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) { if (!acceptsHttpGet(method)) { throw new IllegalArgumentException( "Your logic method must accept HTTP GET method if you want to redirect to it"); } try { String path = request.getContextPath(); String url = router.urlFor(type, method, args); includeParametersInFlash(type, method, args); path = path + url; logger.debug("redirecting to {}", path); response.sendRedirect(path); return null; } catch (IOException e) { throw new ProxyInvocationException(e); } } }); } @Inject  DefaultLogicResult(Proxifier proxifier, Router router, MutableRequest request, MutableResponse response,
			Container container, PathResolver resolver, TypeNameExtractor extractor, FlashScope flash, MethodInfo methodInfo); T forwardTo(final Class<T> type); T redirectTo(final Class<T> type);  }