XmlFlowModelBuilder builder = new XmlFlowModelBuilder(resource, registry);
DefaultFlowModelHolder holder = new DefaultFlowModelHolder(builder);
FlowModelFlowBuilder flowBuilder = new FlowModelFlowBuilder(holder);
FlowAssembler assembler = new FlowAssembler(flowBuilder, new MockFlowBuilderContext("flow"));
Flow flow = assembler.assembleFlow();
FlowExecutionImplFactory factory = new FlowExecutionImplFactory();
factory.setExecutionListenerLoader(new StaticFlowExecutionListenerLoader(new FlowExecutionListenerAdapter() {
public void viewRendering(RequestContext context, View view, StateDefinition viewState) {
if (context.getCurrentEvent() != null && context.getCurrentEvent().getId().equals("submit")) {
BindingResult result = (BindingResult) context.getFlashScope().get(
"org.springframework.validation.BindingResult.formBean");
assertEquals(1, result.getErrorCount());
}
}
public void viewRendered(RequestContext context, View view, StateDefinition viewState) {
if (context.getCurrentEvent() != null && context.getCurrentEvent().getId().equals("submit")) {
BindingResult result = (BindingResult) context.getFlashScope().get(
"org.springframework.validation.BindingResult.formBean");
assertNull(result);
}
}
}));
FlowExecution execution = factory.createFlowExecution(flow);
FormAction action = (FormAction) flow.getApplicationContext().getBean("formAction");
assertFalse(((TestBeanValidator) action.getValidator()).getInvoked());
execution.start(null, new MockExternalContext());
MockExternalContext context = new MockExternalContext();
context.setEventId("submit");