Search in sources :

Example 1 with TransitionCriteriaChain

use of org.springframework.webflow.engine.support.TransitionCriteriaChain in project cas by apereo.

the class CasWebflowConfigurerTests method verifyCriteria.

@Test
public void verifyCriteria() {
    val registry = mock(FlowDefinitionRegistry.class);
    val fbs = mock(FlowBuilderServices.class);
    val cfg = new AbstractCasWebflowConfigurer(fbs, registry, new StaticApplicationContext(), new CasConfigurationProperties()) {
    };
    val transition = mock(Transition.class);
    val criteria = new TransitionCriteriaChain();
    when(transition.getExecutionCriteria()).thenReturn(criteria);
    assertTrue(cfg.getTransitionExecutionCriteriaChainForTransition(transition).isEmpty());
    when(transition.getExecutionCriteria()).thenReturn(mock(TransitionCriteria.class));
    assertFalse(cfg.getTransitionExecutionCriteriaChainForTransition(transition).isEmpty());
}
Also used : lombok.val(lombok.val) StaticApplicationContext(org.springframework.context.support.StaticApplicationContext) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) TransitionCriteriaChain(org.springframework.webflow.engine.support.TransitionCriteriaChain) TransitionCriteria(org.springframework.webflow.engine.TransitionCriteria) Test(org.junit.jupiter.api.Test)

Example 2 with TransitionCriteriaChain

use of org.springframework.webflow.engine.support.TransitionCriteriaChain in project cas by apereo.

the class AbstractCasWebflowConfigurer method createTransition.

@Override
public Transition createTransition(final Expression criteriaOutcomeExpression, final String targetState, final Action... actions) {
    val criteria = getTransitionCriteriaForExpression(criteriaOutcomeExpression);
    val transition = new Transition(criteria, StringUtils.isNotBlank(targetState) ? new DefaultTargetStateResolver(targetState) : null);
    if (actions != null && actions.length > 0) {
        val transitionActionCriteria = Arrays.stream(actions).map(ActionTransitionCriteria::new).toArray(ActionTransitionCriteria[]::new);
        transition.setExecutionCriteria(new TransitionCriteriaChain(transitionActionCriteria));
    }
    return transition;
}
Also used : lombok.val(lombok.val) Transition(org.springframework.webflow.engine.Transition) DefaultTargetStateResolver(org.springframework.webflow.engine.support.DefaultTargetStateResolver) TransitionCriteriaChain(org.springframework.webflow.engine.support.TransitionCriteriaChain)

Example 3 with TransitionCriteriaChain

use of org.springframework.webflow.engine.support.TransitionCriteriaChain in project cas by apereo.

the class AbstractCasWebflowConfigurer method getTransitionExecutionCriteriaChainForTransition.

@Override
public List<TransitionCriteria> getTransitionExecutionCriteriaChainForTransition(final Transition def) {
    if (def.getExecutionCriteria() instanceof TransitionCriteriaChain) {
        val chain = (TransitionCriteriaChain) def.getExecutionCriteria();
        val field = ReflectionUtils.findField(chain.getClass(), "criteriaChain");
        Assert.notNull(field, "criteriaChain cannot be null");
        ReflectionUtils.makeAccessible(field);
        return (List<TransitionCriteria>) ReflectionUtils.getField(field, chain);
    }
    if (def.getExecutionCriteria() != null) {
        return CollectionUtils.wrapList(def.getExecutionCriteria());
    }
    return new ArrayList<>(0);
}
Also used : lombok.val(lombok.val) ArrayList(java.util.ArrayList) TransitionCriteriaChain(org.springframework.webflow.engine.support.TransitionCriteriaChain) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

lombok.val (lombok.val)3 TransitionCriteriaChain (org.springframework.webflow.engine.support.TransitionCriteriaChain)3 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CasConfigurationProperties (org.apereo.cas.configuration.CasConfigurationProperties)1 Test (org.junit.jupiter.api.Test)1 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)1 Transition (org.springframework.webflow.engine.Transition)1 TransitionCriteria (org.springframework.webflow.engine.TransitionCriteria)1 DefaultTargetStateResolver (org.springframework.webflow.engine.support.DefaultTargetStateResolver)1