Package org.amplafi.flow.impl

Examples of org.amplafi.flow.impl.FlowStateImpl


public class TestFlowStateJsonRenderer extends Assert {


    @Test
    public void testSimpleFlowState() {
        FlowStateImpl flowState = newFlowState();
        flowState.clearLookupKey();
        JSONWriter jsonWriter = getJsonWriter();
        jsonWriter.object().key("flowState").value(flowState).endObject();
        assertEquals(jsonWriter.toString(), "{\"flowState\":{\""+FlowStateJsonRenderer.FS_COMPLETE+"\":true,\"" +
                FlowStateJsonRenderer.FS_PARAMETERS+"\":{}" +
            "}}");
View Full Code Here


            "}}");

    }
    @Test
    public void testCompleteFlowState() {
        FlowStateImpl flowState = newFlowState();
        flowState.setRawProperty("property1", "value1");
        flowState.setRawProperty("property2", "value2");
        flowState.clearLookupKey();
        JSONWriter jsonWriter = getJsonWriter();
        jsonWriter.object().key("flowState").value(flowState).endObject();
        assertEquals(jsonWriter.toString(), "{\"flowState\":{\""+FlowStateJsonRenderer.FS_COMPLETE+"\":true,\""+
                FlowStateJsonRenderer.FS_PARAMETERS+"\":{\"property1\":\"value1\",\"property2\":\"value2\"}}}");
    }
View Full Code Here

    private FlowStateImpl newFlowState() {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        String flowTypeName = flowTestingUtils.addFlowDefinition(new FlowActivityImpl());
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        FlowStateImpl flowState = flowManagement.startFlowState(flowTypeName, true, null, null);
        flowState.finishFlow();
        return flowState;
    }
View Full Code Here

            }
        }

        // now as part of a running flow
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        FlowStateImpl flowStateImpl = flowManagement.startFlowState(flowTypeName, true, null, null);
        FlowActivityImpl flowActivity = flowStateImpl.getCurrentActivity();
        for(FlowPropertyProvider flowPropertyProvider: new FlowPropertyProvider[] {flowActivity, flowStateImpl.getFlow()}) {
            namespace = flowLocalProperty.getNamespaceKey(flowStateImpl, flowPropertyProvider);
            assertEquals(namespace, flowStateImpl.getLookupKey());

            namespaces = flowLocalProperty.getNamespaceKeySearchList(flowStateImpl, flowPropertyProvider);
            assertEquals(namespaces.get(0), namespace, "namespaces="+namespaces);
            assertEquals(namespaces.get(1), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(2), null, "namespaces="+namespaces);
            assertEquals(namespaces.size(), 3, "namespaces="+namespaces);
        }
        namespace = activityLocalProperty.getNamespaceKey(flowStateImpl, flowActivity);
        assertTrue(namespace.contains(flowStateImpl.getLookupKey()), "namespace="+namespace+" fsLookupKey="+flowStateImpl.getLookupKey());
        assertTrue(namespace.contains(activityName), "namespace="+namespace);
        namespaces = activityLocalProperty.getNamespaceKeySearchList(flowStateImpl, flowActivity);
        int i = 0;
        assertEquals(namespaces.get(i++), namespace, "namespaces="+namespaces);
        assertEquals(namespaces.get(i++), flowActivity.getFlowPropertyProviderFullName(), "namespaces="+namespaces);
View Full Code Here

        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();

        FlowState fs = new FlowStateImpl(FLOW_TYPE, flowManagement);
        fs.begin();

        assertTrue(fs.hasNext());
        assertTrue(fs.hasVisibleNext());
        assertFalse(fs.hasPrevious());
        assertFalse(fs.hasVisiblePrevious());

        fs.selectActivity(1, true);

        assertFalse(fs.hasNext());
        assertFalse(fs.hasVisibleNext());
        assertTrue(fs.hasPrevious());
        assertTrue(fs.hasVisiblePrevious());
    }
View Full Code Here

        flow.addActivity(fa2);
        flowTestingUtils.getFlowTranslatorResolver().resolve(fa1);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();

        FlowState fs = new FlowStateImpl(FLOW_TYPE, flowManagement);
        fs.begin();

        assertEquals(fs.getCurrentActivityIndex(), 1);
        assertTrue(fs.hasNext());
        assertFalse(fs.hasVisibleNext());
        assertTrue(fs.hasPrevious());
        assertFalse(fs.hasVisiblePrevious());
    }
View Full Code Here

TOP

Related Classes of org.amplafi.flow.impl.FlowStateImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.