private Object[] getParametersFor(ResourceMethod method) { Object[] args = flash.consumeParameters(method); if (args == null) { return provider.getParametersFor(method, errors, localization.getBundle()); } return args; } }
protected <T> void includeParametersInFlash(final Class<T> type, Method method, Object[] args) { if (args != null && args.length != 0) { flash.includeParameters(DefaultControllerMethod.instanceFor(type, method), args); } }
@Test public void shouldPutParametersOnFlashScopeOnRedirect() throws Exception { logicResult.redirectTo(MyComponent.class).withParameter("a"); verify(flash).includeParameters(any(ControllerMethod.class), eq(new Object[] {"a"})); }
private Object[] getParametersForCurrentMethod() { Object[] args = flash.consumeParameters(methodInfo.getControllerMethod()); if (args == null) { return provider.getParametersFor(methodInfo.getControllerMethod(), errors); } return args; } }
@Test public void shouldNotPutParametersOnFlashScopeOnRedirectIfThereAreNoParameters() throws Exception { logicResult.redirectTo(MyComponent.class).base(); verify(flash, never()).includeParameters(any(ControllerMethod.class), any(Object[].class)); }
@Test public void shouldUseAndDiscardFlashParameters() throws InterceptionException, IOException, NoSuchMethodException { Object[] values = new Object[] { new Object() }; when(flash.consumeParameters(method)).thenReturn(values); instantiator.intercept(stack, method, null); verify(params).setParameters(values); verify(stack).next(method, null); verify(validator).addAll(Collections.<Message>emptyList()); verify(parametersProvider, never()).getParametersFor(method, errors, bundle); }