Package org.amplafi.flow.impl

Examples of org.amplafi.flow.impl.FlowActivityImpl


     * Make sure that {@link FlowStateListener} are getting notified.
     */
    @Test
    public void testFlowLifecycleListener() {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        String flowTypeName = flowTestingUtils.addFlowDefinition(new FlowActivityImpl().initInvisible(false));
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        FlowStateLifecycleListenerImpl flowLifecycleStateListener = new FlowStateLifecycleListenerImpl();
        flowManagement.addFlowStateListener(flowLifecycleStateListener);
        FlowState flowState = flowManagement.startFlowState(flowTypeName, true, null, null);
        assertEquals(flowLifecycleStateListener.last, starting);
View Full Code Here


                FlowStateJsonRenderer.FS_PARAMETERS+"\":{\"property1\":\"value1\",\"property2\":\"value2\"}}}");
    }

    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

        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        String activityName = "activity";
        String flowTypeName = "myflow";
        Map<String, String> initialFlowState= new HashMap<String, String>();
        {
            FlowActivityImpl flowActivity = newFlowActivity();
            flowActivity.setFlowPropertyProviderName(activityName);
            for (PropertyScope propertyScope: PropertyScope.values()) {
                for(PropertyUsage propertyUsage: PropertyUsage.values()) {
                    String name= propertyScope+"_"+propertyUsage;
                    String externalInitial = "ext_"+name;
                    FlowPropertyDefinition flowPropertyDefinition = new FlowPropertyDefinitionImpl(name).initAccess(propertyScope, propertyUsage);
                    flowActivity.addPropertyDefinitions(flowPropertyDefinition);
                    initialFlowState.put(name, externalInitial);
                }
            }
            flowTestingUtils.addFlowDefinition(flowTypeName, flowActivity);
        }
View Full Code Here

     */
    @Test(enabled=TEST_ENABLED, dataProvider="exportingPropertiesData")
    public void testExportingProperties(PropertyUsage propertyUsage, PropertyScope propertyScope) {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        FlowPropertyDefinition flowPropertyDefinition = new FlowPropertyDefinitionImpl("testProp", boolean.class).initAccess(propertyScope, propertyUsage);
        FlowActivityImpl flowActivity =newFlowActivity();
        flowActivity.addPropertyDefinitions(flowPropertyDefinition);
        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity);
        FlowState flowState = flowTestingUtils.getFlowManagement().startFlowState(flowTypeName, false, null, null);
        flowState.setProperty("not-a-property", true);
        flowState.setProperty("testProp", true);
        flowState.finishFlow();
View Full Code Here

        FlowPropertyDefinitionImpl flowLocalProperty = new FlowPropertyDefinitionImpl("foo", Boolean.class).initPropertyScope(flowLocal);
        FlowPropertyDefinitionImpl activityLocalProperty = new FlowPropertyDefinitionImpl("foo", Boolean.class).initPropertyScope(activityLocal);
        List<String> namespaces;
        {
            // static test using FlowActivity
            FlowActivityImpl flowActivity = newFlowActivity();
            flowActivity.setFlowPropertyProviderName(activityName);

            flowTestingUtils.addFlowDefinition(flowTypeName, flowActivity);
            namespace = flowLocalProperty.getNamespaceKey(null, flowActivity);
            assertEquals(namespace, flowTypeName);
            namespace = activityLocalProperty.getNamespaceKey(null, flowActivity);
            assertEquals(namespace, flowTypeName+"."+activityName);
            namespaces = flowLocalProperty.getNamespaceKeySearchList(null, flowActivity);
            assertEquals(namespaces.get(0), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(1), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(2), null, "namespaces="+namespaces);
            assertEquals(namespaces.size(), 3, "namespaces="+namespaces);
            namespaces = activityLocalProperty.getNamespaceKeySearchList(null, flowActivity);
            int i = 0;
            assertEquals(namespaces.get(i++), flowActivity.getFullActivityInstanceNamespace(), "namespaces="+namespaces);
            assertEquals(namespaces.get(i++), flowActivity.getFlowPropertyProviderFullName(), "namespaces="+namespaces);
            assertEquals(namespaces.get(i++), flowActivity.getFlowPropertyProviderName(), "namespaces="+namespaces);
            assertEquals(namespaces.get(i++), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(i++), null, "namespaces="+namespaces);
            assertEquals(namespaces.size(), i, "namespaces="+namespaces);
        }

        {
            // static test for FlowImpl
            Flow flow = flowTestingUtils.getFlowDefinitionsManager().getFlowDefinition(flowTypeName);
            namespace = flowLocalProperty.getNamespaceKey(null, flow);
            assertEquals(namespace, flowTypeName);
            namespaces = flowLocalProperty.getNamespaceKeySearchList(null, flow);
            assertEquals(namespaces.get(0), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(1), flowTypeName, "namespaces="+namespaces);
            assertEquals(namespaces.get(2), null, "namespaces="+namespaces);
            assertEquals(namespaces.size(), 3, "namespaces="+namespaces);

            try {
                namespaces = activityLocalProperty.getNamespaceKeySearchList(null, flow);
                fail("should throw exception");
            } catch (IllegalStateException e) {
                // expected
            }
            try {
                namespace = activityLocalProperty.getNamespaceKey(null, flow);
                fail("should throw exception");
            } catch (IllegalStateException e) {
                // expected
            }
        }

        // 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);
        assertEquals(namespaces.get(i++), activityName, "namespaces="+namespaces);
        assertEquals(namespaces.get(i++), flowTypeName, "namespaces="+namespaces);
        assertEquals(namespaces.get(i++), null, "namespaces="+namespaces);
        assertEquals(namespaces.size(), i, "namespaces="+namespaces);
    }
View Full Code Here

    public void testFlowPropertyUsageWithNullInitialization() {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        String propertyName = "propertyName";

        FlowPropertyDefinitionImpl flowLocalProperty = new FlowPropertyDefinitionImpl(propertyName, Boolean.class).initAccess(flowLocal,initialize);
        FlowActivityImpl flowActivity0 = newFlowActivity();
        flowActivity0.setFlowPropertyProviderName("activity0");
        flowActivity0.addPropertyDefinitions(flowLocalProperty);

        FlowActivityImpl flowActivity1 = newFlowActivity();
        flowActivity1.setFlowPropertyProviderName("activity1");
        FlowPropertyDefinitionImpl activityLocalProperty = new FlowPropertyDefinitionImpl(propertyName, Boolean.class).initAccess(activityLocal,internalState);
        flowActivity1.addPropertyDefinitions(activityLocalProperty);

        FlowActivityImpl flowActivity2 = newFlowActivity();
        flowActivity2.setFlowPropertyProviderName("activity2");
        FlowPropertyDefinitionImpl globalProperty = new FlowPropertyDefinitionImpl(propertyName, Boolean.class).initAccess(flowLocal,io);
        flowActivity2.addPropertyDefinitions(globalProperty);

        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0, flowActivity1, flowActivity2);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "true");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
View Full Code Here

    public void testFlowPropertyUsage() {
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        String propertyName = "propertyName";

        FlowPropertyDefinitionImpl flowLocalProperty = new FlowPropertyDefinitionImpl(propertyName, String.class).initAccess(flowLocal,initialize).initInitial("true");
        FlowActivityImpl flowActivity0 = newFlowActivity();
        flowActivity0.setFlowPropertyProviderName("activity0");
        flowActivity0.addPropertyDefinitions(flowLocalProperty);

        FlowActivityImpl flowActivity1 = newFlowActivity();
        flowActivity1.setFlowPropertyProviderName("activity1");
        FlowPropertyDefinitionImpl activityLocalProperty = new FlowPropertyDefinitionImpl(propertyName, String.class).initAccess(activityLocal,internalState);
        flowActivity1.addPropertyDefinitions(activityLocalProperty);

        FlowActivityImpl flowActivity2 = newFlowActivity();
        flowActivity2.setFlowPropertyProviderName("activity2");
        FlowPropertyDefinitionImpl globalProperty = new FlowPropertyDefinitionImpl(propertyName, String.class).initAccess(flowLocal,io);
        flowActivity2.addPropertyDefinitions(globalProperty);

        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0, flowActivity1, flowActivity2);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "maybe");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
View Full Code Here

    /**
     * @return
     */
    private FlowActivityImpl newFlowActivity() {
        return new FlowActivityImpl().initInvisible(false);
    }
View Full Code Here

    public void testEnumHandling() {
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState("foo", SampleEnum.EXTERNAL);
        FlowImplementor flow = new FlowImpl(FLOW_TYPE);
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("foo", SampleEnum.class);
        flow.addPropertyDefinitions(definition);
        FlowActivityImpl fa1 = new FlowActivityImpl().initInvisible(false);
        definition = new FlowPropertyDefinitionImpl("fa1fp", SampleEnum.class).initInitial(SampleEnum.EMAIL.name());
        fa1.addPropertyDefinitions(definition);
        flow.addActivity(fa1);
        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
View Full Code Here

            @Override
            public Class<FlowPropertyProvider> getFlowPropertyProviderClass() {
                return FlowPropertyProvider.class;
            }
        });
        FlowActivityImpl flowActivity0 = newFlowActivity();
        flowActivity0.setFlowPropertyProviderName("activity0");
        flowActivity0.addPropertyDefinitions(flowLocalProperty);
        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "maybe");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
        assertNotNull(flowState);
View Full Code Here

TOP

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

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.