Search in sources :

Example 1 with Path

use of alien4cloud.paas.wf.model.Path in project alien4cloud by alien4cloud.

the class GraphPathsTest method testCycles.

@Test
public void testCycles() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    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, a);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    System.out.println(paths);
    Assert.assertEquals(1, paths.size());
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Example 2 with Path

use of alien4cloud.paas.wf.model.Path in project alien4cloud by alien4cloud.

the class GraphPathsTest method test23.

/**
 * <pre>
 *      c
 *     /
 * -- a
 *     \
 *      b
 * </pre>
 */
@Test
public void test23() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    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(a, c);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Example 3 with Path

use of alien4cloud.paas.wf.model.Path in project alien4cloud by alien4cloud.

the class GraphPathsTest method testOrphan.

/**
 * <pre>
 *     -- a --
 *    /       \
 *    \       /
 *     -- b --
 * </pre>
 */
@Test
public void testOrphan() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowUtils.linkSteps(a, b);
    WorkflowUtils.linkSteps(b, a);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    System.out.println(paths);
    Assert.assertEquals(1, paths.size());
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Example 4 with Path

use of alien4cloud.paas.wf.model.Path in project alien4cloud by alien4cloud.

the class CycleDetection method validate.

@Override
public List<AbstractWorkflowError> validate(TopologyContext topologyContext, Workflow workflow) {
    if (workflow.getSteps() == null || workflow.getSteps().isEmpty()) {
        return null;
    }
    List<AbstractWorkflowError> result = Lists.newArrayList();
    // get all the paths
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(workflow);
    for (Path path : paths) {
        // isolate cycles
        result.add(new WorkflowHasCycleError(extractCycle(path.getStepNames())));
    }
    return result;
}
Also used : Path(alien4cloud.paas.wf.model.Path)

Example 5 with Path

use of alien4cloud.paas.wf.model.Path in project alien4cloud by alien4cloud.

the class GraphPathsTest method test1.

/**
 * a -- b
 */
@Test
public void test1() {
    Workflow wf = new Workflow();
    wf.setName(INSTALL);
    WorkflowStep a = wf.addStep(new SimpleStep("a"));
    WorkflowStep b = wf.addStep(new SimpleStep("b"));
    WorkflowUtils.linkSteps(a, b);
    List<Path> paths = WorkflowGraphUtils.getWorkflowGraphCycles(wf);
    log.info(paths.toString());
}
Also used : Path(alien4cloud.paas.wf.model.Path) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) Test(org.junit.Test)

Aggregations

Path (alien4cloud.paas.wf.model.Path)8 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)7 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)1 NodeWorkflowStep (org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)1 RelationshipWorkflowStep (org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep)1