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());
}
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;
}
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);
}
Aggregations