public Model createCopy() { FlowModel copy = new FlowModel(); copy.setAbstract(abztract); copy.setParent(parent); copy.setStartStateId(startStateId); copy.setAttributes(copyList(attributes)); copy.setSecured((SecuredModel) copy(secured)); copy.setPersistenceContext((PersistenceContextModel) copy(persistenceContext)); copy.setVars(copyList(vars)); copy.setInputs(copyList(inputs)); copy.setOutputs(copyList(outputs)); copy.setOnStartActions(copyList(onStartActions)); copy.setStates(copyList(states)); copy.setGlobalTransitions(copyList(globalTransitions)); copy.setOnEndActions(copyList(onEndActions)); copy.setExceptionHandlers(copyList(exceptionHandlers)); copy.setBeanImports(copyList(beanImports)); return copy; }
public void merge(Model model) { FlowModel flow = (FlowModel) model; setParent(null); setStartStateId(merge(getStartStateId(), flow.getStartStateId())); setAttributes(merge(getAttributes(), flow.getAttributes())); setSecured((SecuredModel) merge(getSecured(), flow.getSecured())); setPersistenceContext((PersistenceContextModel) merge(getPersistenceContext(), flow.getPersistenceContext())); setVars(merge(getVars(), flow.getVars(), false)); setInputs(merge(getInputs(), flow.getInputs())); setOutputs(merge(getOutputs(), flow.getOutputs())); setOnStartActions(merge(getOnStartActions(), flow.getOnStartActions(), false)); setStates(merge(getStates(), flow.getStates())); setGlobalTransitions(merge(getGlobalTransitions(), flow.getGlobalTransitions())); setOnEndActions(merge(getOnEndActions(), flow.getOnEndActions(), false)); setExceptionHandlers(merge(getExceptionHandlers(), flow.getExceptionHandlers())); setBeanImports(merge(getBeanImports(), flow.getBeanImports())); }
private AttributeMap<Object> parseFlowMetaAttributes(FlowModel flow) { MutableAttributeMap<Object> flowAttributes = parseMetaAttributes(flow.getAttributes()); parseAndPutPersistenceContext(flow.getPersistenceContext(), flowAttributes); parseAndPutSecured(flow.getSecured(), flowAttributes); return flowAttributes; }
public void testMergeVars() { FlowModel parent = new FlowModel(); parent.setVars(asList(new VarModel("name", "value"))); FlowModel child = new FlowModel(); child.setVars(asList(new VarModel("name", "value2"))); child.merge(parent); assertEquals(1, child.getVars().size()); assertEquals("value2", child.getVars().get(0).getClassName()); }
public void testSetActionWithResultType() throws Exception { SetModel setModel = new SetModel("flowScope.stringArray", "intArray"); setModel.setType("java.lang.String[]"); model.setOnStartActions(asList(setModel)); model.setStates(asList(new ViewStateModel("view"))); Flow flow = getFlow(model); AnnotatedAction action = (AnnotatedAction) flow.getStartActionList().get(0); MockRequestContext context = new MockRequestContext(flow); context.getFlowScope().put("intArray", new int[] { 1, 2 }); action.execute(context); String[] expected = (String[]) context.getFlowScope().get("stringArray"); assertEquals("1", expected[0]); assertEquals("2", expected[1]); }
public void testMergePersistenceContext() { FlowModel child = new FlowModel(); FlowModel parent = new FlowModel(); parent.setPersistenceContext(new PersistenceContextModel()); child.merge(parent); assertNotNull(child.getPersistenceContext()); }
public void testMergeStates() { FlowModel child = new FlowModel(); child.setStates(asList(new ViewStateModel("view"), new EndStateModel("end"))); FlowModel parent = new FlowModel(); ViewStateModel view = new ViewStateModel("view"); view.setView("jsp"); parent.setStates(asList(view, new DecisionStateModel("decider"), new ActionStateModel("action"))); child.merge(parent); assertEquals(4, child.getStates().size()); assertEquals("jsp", ((ViewStateModel) child.getStates().get(0)).getView()); }
public void testMergeOnStart() { FlowModel child = new FlowModel(); child.setOnStartActions(asList(new EvaluateModel("expression"), new RenderModel( "expression"), new SetModel("expression", "value"))); FlowModel parent = new FlowModel(); EvaluateModel eval = new EvaluateModel("expression"); eval.setResult("result"); parent.setOnStartActions(asList(eval, new RenderModel("expression"), new SetModel( "expression", "value"))); child.merge(parent); assertEquals(6, child.getOnStartActions().size()); assertNotNull(((EvaluateModel) child.getOnStartActions().get(0)).getResult()); }
public void testMergeGlobalTransitions() { FlowModel child = new FlowModel(); TransitionModel transition1 = new TransitionModel(); transition1.setOn("end"); TransitionModel transition2 = new TransitionModel(); transition2.setOn("start"); child.setGlobalTransitions(asList(transition1, transition2)); FlowModel parent = new FlowModel(); transition1 = new TransitionModel(); transition1.setOn("search"); transition2 = new TransitionModel(); transition2.setOn("end"); transition2.setTo("theend"); parent.setGlobalTransitions(asList(transition1, transition2)); child.merge(parent); assertEquals(3, child.getGlobalTransitions().size()); assertEquals("theend", child.getGlobalTransitions().get(0).getTo()); }
public void testMergeSecured() { FlowModel child = new FlowModel(); FlowModel parent = new FlowModel(); child.setSecured(new SecuredModel("secured")); SecuredModel secured = new SecuredModel("secured"); secured.setMatch("all"); parent.setSecured(secured); child.merge(parent); assertEquals("all", child.getSecured().getMatch()); }
public void testMergeExceptionHandlers() { FlowModel child = new FlowModel(); child.setExceptionHandlers(asList(new ExceptionHandlerModel("bean1"), new ExceptionHandlerModel("bean2"))); FlowModel parent = new FlowModel(); parent.setExceptionHandlers(asList(new ExceptionHandlerModel("bean2"), new ExceptionHandlerModel("bean3"))); child.merge(parent); assertEquals(4, child.getExceptionHandlers().size()); }
public void testMergeBeanImports() { FlowModel child = new FlowModel(); child.setBeanImports(asList(new BeanImportModel("path1"), new BeanImportModel("path2"))); FlowModel parent = new FlowModel(); parent.setBeanImports(asList(new BeanImportModel("path1"), new BeanImportModel("path2"))); child.merge(parent); assertEquals(4, child.getBeanImports().size()); }
public void testMergeOnEnd() { FlowModel child = new FlowModel(); child.setOnEndActions(asList(new EvaluateModel("expression"), new RenderModel("expression"), new SetModel("expression", "value"))); FlowModel parent = new FlowModel(); EvaluateModel eval = new EvaluateModel("expression"); eval.setResult("result"); parent.setOnEndActions(asList(eval, new RenderModel("expression"), new SetModel( "expression", "value"))); child.merge(parent); assertEquals(6, child.getOnEndActions().size()); assertNotNull(((EvaluateModel) child.getOnEndActions().get(0)).getResult()); }
public void testMergeAttributes() { FlowModel child = new FlowModel(); FlowModel parent = new FlowModel(); child.setAttributes(asList(new AttributeModel("name", "value"))); AttributeModel parentAttribute1 = new AttributeModel("name", "value"); parentAttribute1.setType("type"); AttributeModel parentAttribute2 = new AttributeModel("name2", "value2"); parentAttribute2.setType("type2"); parent.setAttributes(asList(parentAttribute1, parentAttribute2)); child.merge(parent); assertEquals(2, child.getAttributes().size()); assertEquals("name", child.getAttributes().get(0).getName()); assertEquals("type", child.getAttributes().get(0).getType()); assertEquals("name2", child.getAttributes().get(1).getName()); assertEquals("type2", child.getAttributes().get(1).getType()); }
public void testMergeMappings() { FlowModel child = new FlowModel(); FlowModel parent = new FlowModel(); InputModel input1 = new InputModel("name", "value"); input1.setType("type"); input1.setType("required"); InputModel input2 = new InputModel("name2", "value2"); input2.setType("type2"); input2.setRequired("required2"); InputModel input3 = new InputModel("name3", "value3"); input2.setType("type3"); input2.setRequired("required3"); child.setInputs(asList(input1, input2, input3)); InputModel parentInput = new InputModel("name3", "value3"); parentInput.setType("type3"); parentInput.setRequired("required3"); parent.setInputs(asList(parentInput)); child.merge(parent); assertEquals(3, child.getInputs().size()); }
/** * Sets states. * * @param states the states */ public void setStates(final List<AbstractStateModel> states) { this.flowModel.setStates(new LinkedList<>(states)); }
public void testExceptionHandlers() { FlowModel model = new FlowModel(); model.setStates(asList(new EndStateModel("state"))); model.setExceptionHandlers(asList(new ExceptionHandlerModel("exceptionHandler"))); FlowExecutionExceptionHandler handler = new FlowExecutionExceptionHandler() { public boolean canHandle(FlowExecutionException exception) { return true; } public void handle(FlowExecutionException exception, RequestControlContext context) { } }; FlowModelFlowBuilder builder = new FlowModelFlowBuilder(new StaticFlowModelHolder(model)); MockFlowBuilderContext context = new MockFlowBuilderContext("foo"); context.registerBean("exceptionHandler", handler); FlowAssembler assembler = new FlowAssembler(builder, context); Flow flow = assembler.assembleFlow(); assertEquals(1, flow.getExceptionHandlerSet().size()); }
/** * Creates and adds all exception handlers to the flow built by this builder. * @throws FlowBuilderException an exception occurred building this flow */ public void buildExceptionHandlers() throws FlowBuilderException { getFlow().getExceptionHandlerSet().addAll( parseExceptionHandlers(flowModel.getExceptionHandlers(), flowModel.getGlobalTransitions())); }
InputModel input4 = new InputModel("required", "flowScope.boop"); input4.setRequired("true"); model.setInputs(asList(input1, input2, input3, input4)); output3.setRequired("true"); OutputModel output4 = new OutputModel("literal", "'a literal'"); model.setOutputs(asList(output1, output2, output3, output4)); notReached.setOutputs(asList(new OutputModel("notReached", "flowScope.foo"))); model.setStates(asList(end, notReached));