public void testEnter() { new State(subflow, "whatev") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; subflowState.enter(context); assertEquals("child", context.getActiveFlow().getId()); }
@SuppressWarnings("unchecked") public void testEnterWithInput() { subflowState.setAttributeMapper(new SubflowAttributeMapper() { public MutableAttributeMap<Object> createSubflowInput(RequestContext context) { return new LocalAttributeMap<>("foo", "bar"); } public void mapSubflowOutput(AttributeMap<?> flowOutput, RequestContext context) { } }); subflow.setInputMapper((source, target) -> { MutableAttributeMap<Object> map = (MutableAttributeMap<Object>) source; assertEquals("bar", map.get("foo")); return new DefaultMappingResults(source, target, Collections.emptyList()); }); new State(subflow, "whatev") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; subflowState.enter(context); assertEquals("child", context.getActiveFlow().getId()); }
@SuppressWarnings("unchecked") public void testReturnWithOutput() { subflowState.setAttributeMapper(new SubflowAttributeMapper() { public MutableAttributeMap<Object> createSubflowInput(RequestContext context) { return new LocalAttributeMap<>(); } public void mapSubflowOutput(AttributeMap<?> flowOutput, RequestContext context) { assertEquals("bar", flowOutput.get("foo")); } }); subflowState.getTransitionSet().add(new Transition(on("end"), to("whatev"))); new State(parentFlow, "whatev") { protected void doEnter(RequestControlContext context) throws FlowExecutionException { } }; new EndState(subflow, "end"); subflow.setOutputMapper((source, target) -> { MutableAttributeMap<Object> map = (MutableAttributeMap<Object>) target; map.put("foo", "bar"); return new DefaultMappingResults(source, target, Collections.emptyList()); }); subflowState.enter(context); assertEquals("parent", context.getActiveFlow().getId()); }