Search in sources :

Example 6 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class AbstractCasWebflowConfigurer method addActionsToActionStateExecutionListAt.

/**
 * Add actions to action state execution list at.
 *
 * @param flow          the flow
 * @param actionStateId the action state id
 * @param position      the position
 * @param actions       the actions
 */
public void addActionsToActionStateExecutionListAt(final Flow flow, final String actionStateId, final int position, final EvaluateAction... actions) {
    val actionState = getState(flow, actionStateId, ActionState.class);
    val actionList = actionState.getActionList();
    val currentActions = new ArrayList<Action>(actionList.size() + actions.length);
    actionList.forEach(currentActions::add);
    val index = position < 0 || position == Integer.MAX_VALUE ? currentActions.size() : position;
    currentActions.forEach(actionList::remove);
    Arrays.stream(actions).forEach(a -> currentActions.add(index, a));
    actionList.addAll(currentActions.toArray(Action[]::new));
}
Also used : lombok.val(lombok.val) SetAction(org.springframework.webflow.action.SetAction) Action(org.springframework.webflow.execution.Action) ExternalRedirectAction(org.springframework.webflow.action.ExternalRedirectAction) EvaluateAction(org.springframework.webflow.action.EvaluateAction) RenderAction(org.springframework.webflow.action.RenderAction) ArrayList(java.util.ArrayList)

Example 7 with EvaluateAction

use of org.springframework.webflow.action.EvaluateAction in project cas by apereo.

the class CasWebflowConfigurerTests method verifyExpression.

@Test
public void verifyExpression() {
    val registry = mock(FlowDefinitionRegistry.class);
    val fbs = mock(FlowBuilderServices.class);
    when(fbs.getConversionService()).thenReturn(mock(ConversionService.class));
    val cfg = new AbstractCasWebflowConfigurer(fbs, registry, new StaticApplicationContext(), new CasConfigurationProperties()) {
    };
    val action = new EvaluateAction(cfg.createExpression("example"), cfg.createExpression("result"));
    assertNotNull(cfg.getExpressionStringFromAction(action));
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) ConversionService(org.springframework.binding.convert.ConversionService) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) EvaluateAction(org.springframework.webflow.action.EvaluateAction) Test(org.junit.jupiter.api.Test)

Aggregations

EvaluateAction (org.springframework.webflow.action.EvaluateAction)7 lombok.val (lombok.val)6 Test (org.junit.jupiter.api.Test)2 FluentParserContext (org.springframework.binding.expression.support.FluentParserContext)2 SetAction (org.springframework.webflow.action.SetAction)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 CasCaptchaConfiguration (org.apereo.cas.web.flow.config.CasCaptchaConfiguration)1 Assertions (org.junit.jupiter.api.Assertions)1 Tag (org.junit.jupiter.api.Tag)1 ConversionService (org.springframework.binding.convert.ConversionService)1 Expression (org.springframework.binding.expression.Expression)1 ParserContext (org.springframework.binding.expression.ParserContext)1 LiteralExpression (org.springframework.binding.expression.support.LiteralExpression)1 Import (org.springframework.context.annotation.Import)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 ExternalRedirectAction (org.springframework.webflow.action.ExternalRedirectAction)1 RenderAction (org.springframework.webflow.action.RenderAction)1 ActionState (org.springframework.webflow.engine.ActionState)1