Search in sources :

Example 31 with WorkflowStep

use of org.alien4cloud.tosca.model.workflow.WorkflowStep in project alien4cloud by alien4cloud.

the class CycleDetectionTest method testTwoSequencedCycles.

/**
 * <pre>
 *
 *        c         f
 *       /  \      /  \
 * a -- b -- d -- e -- g
 *
 * </pre>
 */
@Test()
public void testTwoSequencedCycles() {
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowStep c = wf.addStep(new SimpleStep("c"));
    WorkflowStep d = wf.addStep(new SimpleStep("d"));
    WorkflowStep e = wf.addStep(new SimpleStep("e"));
    WorkflowStep f = wf.addStep(new SimpleStep("f"));
    WorkflowStep g = wf.addStep(new SimpleStep("g"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(b, d);
    WorkflowUtils.linkSteps(d, c);
    WorkflowUtils.linkSteps(c, b);
    WorkflowUtils.linkSteps(d, e);
    WorkflowUtils.linkSteps(e, g);
    WorkflowUtils.linkSteps(g, f);
    WorkflowUtils.linkSteps(f, e);
    processValidation(true, 2);
}
Also used : WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Test(org.junit.Test)

Example 32 with WorkflowStep

use of org.alien4cloud.tosca.model.workflow.WorkflowStep in project alien4cloud by alien4cloud.

the class CycleDetectionTest method testForkJoinNoCycle.

/**
 * <pre>
 *      -- b
 *     /
 * a --
 *     \
 *      -- c -- d -- e
 * </pre>
 */
@Test
public void testForkJoinNoCycle() {
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowStep c = wf.addStep(new SimpleStep("c"));
    WorkflowStep d = wf.addStep(new SimpleStep("d"));
    WorkflowStep e = wf.addStep(new SimpleStep("e"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(a, c);
    WorkflowUtils.linkSteps(c, d);
    WorkflowUtils.linkSteps(d, e);
    processValidation(false, 0);
}
Also used : WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Test(org.junit.Test)

Example 33 with WorkflowStep

use of org.alien4cloud.tosca.model.workflow.WorkflowStep in project alien4cloud by alien4cloud.

the class CycleDetectionTest method testIndirectCycle.

/**
 * <pre>
 *        --
 *       /  \
 * a -- b    c
 *       \  /
 *        --
 * </pre>
 */
@Test
public void testIndirectCycle() {
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowStep c = wf.addStep(new SimpleStep("c"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(b, c);
    WorkflowUtils.linkSteps(c, b);
    processValidation(true, 1);
}
Also used : WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Test(org.junit.Test)

Example 34 with WorkflowStep

use of org.alien4cloud.tosca.model.workflow.WorkflowStep in project alien4cloud by alien4cloud.

the class CycleDetectionTest method test2StepsCycle.

/**
 * <pre>
 *    --
 *   /  \
 *  a    b
 *   \  /
 *    --
 * </pre>
 */
@Test
public void test2StepsCycle() {
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(b, a);
    processValidation(true, 1);
}
Also used : WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Test(org.junit.Test)

Example 35 with WorkflowStep

use of org.alien4cloud.tosca.model.workflow.WorkflowStep in project alien4cloud by alien4cloud.

the class CycleDetectionTest method testTwoParallelCycles.

/**
 * <pre>
 *           --- c
 *          /     \
 *      -- b ----- d
 *     /
 * a --      f
 *     \    /  \
 *      -- e -- g
 *
 * </pre>
 */
@Test()
public void testTwoParallelCycles() {
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowStep c = wf.addStep(new SimpleStep("c"));
    WorkflowStep d = wf.addStep(new SimpleStep("d"));
    WorkflowStep e = wf.addStep(new SimpleStep("e"));
    WorkflowStep f = wf.addStep(new SimpleStep("f"));
    WorkflowStep g = wf.addStep(new SimpleStep("g"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(b, c);
    WorkflowUtils.linkSteps(c, d);
    WorkflowUtils.linkSteps(d, b);
    WorkflowUtils.linkSteps(a, e);
    WorkflowUtils.linkSteps(a, e);
    WorkflowUtils.linkSteps(e, f);
    WorkflowUtils.linkSteps(f, g);
    WorkflowUtils.linkSteps(g, e);
    processValidation(true, 2);
}
Also used : WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Test(org.junit.Test)

Aggregations

WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)51 RelationshipWorkflowStep (org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep)24 NodeWorkflowStep (org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)23 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)20 Test (org.junit.Test)17 Path (alien4cloud.paas.wf.model.Path)7 Map (java.util.Map)6 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)5 InconsistentWorkflowException (alien4cloud.paas.wf.exception.InconsistentWorkflowException)4 TopologyDTO (alien4cloud.topology.TopologyDTO)4 AlienUtils.safe (alien4cloud.utils.AlienUtils.safe)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)3 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)3 StringUtils (org.apache.commons.lang3.StringUtils)3