Package org.amplafi.flow.impl

Examples of org.amplafi.flow.impl.FlowImpl


     * Test simple flow definitions and instances.
     *
     */
    @Test(enabled=TEST_ENABLED)
    public void testFlowDefinition() {
        FlowImpl flow = new FlowImpl();
        FlowActivity[] fas = new FlowActivity[3];
        for(int i = 0; i < fas.length; i++) {
            FlowActivityImpl fa = new FlowActivityImpl();
            fas[i] = fa;
            flow.addActivity(fa);
        }
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
        for(int i=0; i < fas.length; i++) {
            // make sure order is preserved.
            assertSame(flow.getActivity(i), fas[i]);
            // check that in definition all was as defined.
            assertFalse(fas[i].isActivatable());
            assertFalse(fas[i].isFinishingActivity());
        }

        Flow instance = flow.createInstance();
        List<FlowActivityImplementor> ifas = instance.getActivities();

        // make sure they are different and definition has not changed.
        for(int i=0; i < fas.length; i++) {
            // make sure order is preserved.
View Full Code Here


            FlowActivityImpl flowActivity0 = new FlowActivityImpl();
            flowActivity0.setFlowPropertyProviderName("fs0");
            flowActivity0.addPropertyDefinitions(new FlowPropertyDefinitionImpl("key").initPropertyScope(activityLocal));
            FlowActivityImpl flowActivity1 = new FlowActivityImpl();
            flowActivity1.setFlowPropertyProviderName("fs1");
            FlowImpl flow = new FlowImpl(FLOW_TYPE, flowActivity0, flowActivity1);
            flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
            flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        }
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(
View Full Code Here

    /**
     * Test for hasVisibleNext and hasVisiblePrevious of FlowState.
     */
    @Test(enabled=TEST_ENABLED)
    public void testVisiblePreviousNext() {
        FlowImpl flow = new FlowImpl(FLOW_TYPE);
        flow.addActivity(new FlowActivityImpl().initInvisible(false));
        flow.addActivity(new FlowActivityImpl().initInvisible(false));
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();

View Full Code Here

     *
     * Also test when invisible is turned on/off during the flow.
     */
    @Test(enabled=TEST_ENABLED)
    public void testVisiblePreviousNextWithHidden() {
        FlowImplementor flow = new FlowImpl(FLOW_TYPE);
        FlowActivityImpl fa1 = new FlowActivityImpl().initInvisible(true);
        FlowActivityImpl fa2 = new FlowActivityImpl().initInvisible(true);
        FlowActivityImpl fa3 = new FlowActivityImpl().initInvisible(false);
        flow.addActivity(fa1);
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolve(fa1);
        flow.addActivity(fa3);
        flowTestingUtils.getFlowTranslatorResolver().resolve(fa3);
        flow.addActivity(fa2);
        flowTestingUtils.getFlowTranslatorResolver().resolve(fa1);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();

        FlowState fs = new FlowStateImpl(FLOW_TYPE, flowManagement);
View Full Code Here

        assertFalse(fs.hasVisiblePrevious());
    }

    @Test(enabled=TEST_ENABLED)
    public void testInitialValuesOnFlow() {
        FlowImplementor flow = new FlowImpl(FLOW_TYPE);
        FlowPropertyDefinitionImpl globalDef = new FlowPropertyDefinitionImpl(PROPERTY1);
        globalDef.setInitial(INITIAL_VALUE);
        flow.addPropertyDefinitions(globalDef);
        FlowPropertyDefinitionImpl globalDef1 = new FlowPropertyDefinitionImpl(PROPERTY2);
        globalDef1.setInitial(INITIAL_VALUE);
        flow.addPropertyDefinitions(globalDef1);
        // activity #0
        FlowActivityImpl activity = new FlowActivityImpl();
        flow.addActivity(activity);
        // activity #1
        activity = new FlowActivityImpl();
        flow.addActivity(activity);
        // activity #2
        activity = new FlowActivityImpl();
        FlowPropertyDefinitionImpl localDef1 = new FlowPropertyDefinitionImpl(PROPERTY1);
        activity.addPropertyDefinitions(localDef1);
        flow.addActivity(activity);
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);

        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
View Full Code Here

    @Test(enabled=TEST_ENABLED)
    public void testConversion() {
        String returnToFlowLookupKey = null;
        Map<String, String> initialFlowState = new HashMap<String, String>();
        FlowImplementor flow = new FlowImpl(FLOW_TYPE);
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("foo", Long.class);
        flow.addPropertyDefinitions(definition);
        FlowActivityImpl fa1 = new FlowActivityImpl();
        flow.addActivity(fa1);
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolve(fa1);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        FlowState flowState = flowManagement.startFlowState(FLOW_TYPE, true, initialFlowState, returnToFlowLookupKey);
View Full Code Here

    private static final String FLOW_TYPE_2 = "ftype2";
    private static final String FLOW_TYPE_3 = "ftype3";
    private static final boolean TEST_ENABLED = true;
    @Test(enabled=TEST_ENABLED)
    public void testSimpleFlowTransitionMapChecking() {
        FlowImpl flow = new FlowImpl(FLOW_TYPE_1);
        FlowActivityImpl fa1 = new FlowActivityImpl().initInvisible(false);
        FlowPropertyDefinitionImplementor definition = fa1.getFlowPropertyDefinition(FSFLOW_TRANSITIONS);
        assertNull(definition);
        flow.addActivity(fa1);
        definition = fa1.getFlowPropertyDefinition(FSFLOW_TRANSITIONS);
        assertNotNull(definition);
        String returnToFlowLookupKey = null;
        definition.setFlowPropertyValueProvider(new AddToMapFlowPropertyValueProvider<FlowPropertyProvider, String,FlowTransition>(new FlowTransition("foo", FLOW_TYPE_2, "foo", TransitionType.alternate, null)));
        FlowManagement baseFlowManagement = getFlowManagement(flow);
View Full Code Here

     * check to make sure the flow returns to the original flow
     * check to make sure the altered value is returned to
     */
    @Test(enabled=TEST_ENABLED)
    public void testReturnToFlow() {
        FlowImpl mainFlow = new FlowImpl(FLOW_TYPE_1);
        String defaultAfterPage1 = "default-after-page-for-"+FLOW_TYPE_1;
        String defaultPage1 = "page-of-"+FLOW_TYPE_1;
        mainFlow.setPageName(defaultPage1);
        mainFlow.setDefaultAfterPage(defaultAfterPage1);
        FlowActivityImpl fa1 = new FlowActivityImpl().initInvisible(false);
        FlowPropertyDefinitionImpl copiedBackProperty = new FlowPropertyDefinitionImpl("copiedBackProperty").initAccess(PropertyScope.flowLocal, PropertyUsage.io);
        fa1.addPropertyDefinition(copiedBackProperty);
        mainFlow.addActivity(fa1);

        FlowImpl subFlow = new FlowImpl(FLOW_TYPE_2);
        String defaultAfterPage2 = "default-after-page-for-"+FLOW_TYPE_2;
        String defaultPage2 = "page-of-"+FLOW_TYPE_2;
        subFlow.setPageName(defaultPage2);
        subFlow.setDefaultAfterPage(defaultAfterPage2);
        FlowActivityImpl fa2_1 = new FlowActivityImpl().initInvisible(false);
        fa2_1.addPropertyDefinition(copiedBackProperty.clone());
        subFlow.addActivity(fa2_1);
        subFlow.addActivity(new TransitionFlowActivity());

        FlowImpl continuedFlow = new FlowImpl(FLOW_TYPE_3);
        String defaultAfterPage3 = "default-after-page-for-"+FLOW_TYPE_3;
        String defaultPage3 = "page-of-"+FLOW_TYPE_3;
        continuedFlow.setPageName(defaultPage3);
        continuedFlow.setDefaultAfterPage(defaultAfterPage3);
        FlowActivityImpl fa3_1 = new FlowActivityImpl().initInvisible(false);
        continuedFlow.addActivity(fa3_1);

        Object returnToFlowLookupKey = true;
        FlowManagement baseFlowManagement = getFlowManagement(mainFlow, subFlow, continuedFlow);
        FlowState flowState1 = baseFlowManagement.startFlowState(FLOW_TYPE_1, true, null, returnToFlowLookupKey);
        assertEquals(flowState1.getCurrentPage(), defaultPage1);
View Full Code Here

TOP

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

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.