Search in sources :

Example 1 with ProcessValidationError

use of io.automatiko.engine.workflow.base.core.validation.ProcessValidationError in project automatiko-engine by automatiko-io.

the class ExecutableProcessValidator method validateProcess.

public ProcessValidationError[] validateProcess(final ExecutableProcess process) {
    final List<ProcessValidationError> errors = new ArrayList<>();
    if (process.getName() == null) {
        errors.add(new ProcessValidationErrorImpl(process, "Process has no name."));
    }
    if (process.getId() == null || "".equals(process.getId())) {
        errors.add(new ProcessValidationErrorImpl(process, "Process has no id."));
    }
    // check start node of process
    if (process.getStartNodes().isEmpty() && !process.isDynamic()) {
        errors.add(new ProcessValidationErrorImpl(process, "Process has no start node."));
    }
    // Check end node of the process.
    if (process.getEndNodes().isEmpty() && !process.isDynamic()) {
        errors.add(new ProcessValidationErrorImpl(process, "Process has no end node."));
    }
    validateNodes(process.getNodes(), errors, process);
    validateVariables(errors, process);
    checkAllNodesConnectedToStart(process, process.isDynamic(), errors, process);
    return errors.toArray(new ProcessValidationError[errors.size()]);
}
Also used : ArrayList(java.util.ArrayList) ProcessValidationErrorImpl(io.automatiko.engine.workflow.base.core.validation.impl.ProcessValidationErrorImpl) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError)

Example 2 with ProcessValidationError

use of io.automatiko.engine.workflow.base.core.validation.ProcessValidationError in project automatiko-engine by automatiko-io.

the class RuleFlowProcessValidatorTest method testEmptyPackageName.

@Test
void testEmptyPackageName() {
    ExecutableProcess process = new ExecutableProcess();
    process.setId("org.company.core.process");
    process.setName("Empty Package Name Process");
    process.setPackageName("");
    process.setDynamic(true);
    ProcessValidationError[] errors = validator.validateProcess(process);
    assertNotNull(errors);
    assertEquals(0, errors.length);
}
Also used : ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Example 3 with ProcessValidationError

use of io.automatiko.engine.workflow.base.core.validation.ProcessValidationError in project automatiko-engine by automatiko-io.

the class RuleFlowProcessValidatorTest method testNoPackageName.

@Test
void testNoPackageName() {
    ExecutableProcess process = new ExecutableProcess();
    process.setId("org.company.core.process");
    process.setName("No Package Name Process");
    process.setDynamic(true);
    ProcessValidationError[] errors = validator.validateProcess(process);
    assertNotNull(errors);
    assertEquals(0, errors.length);
}
Also used : ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Example 4 with ProcessValidationError

use of io.automatiko.engine.workflow.base.core.validation.ProcessValidationError in project automatiko-engine by automatiko-io.

the class RuleFlowProcessValidatorTest method testCompositeNodeNoStart.

@Test
void testCompositeNodeNoStart() {
    ExecutableProcess process = new ExecutableProcess();
    process.setId("org.company.core.process.process");
    process.setName("Process");
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    process.addNode(startNode);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(2);
    process.addNode(endNode);
    CompositeNode compositeNode = new CompositeNode();
    compositeNode.setName("CompositeNode");
    compositeNode.setId(3);
    process.addNode(compositeNode);
    new io.automatiko.engine.workflow.process.core.impl.ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, compositeNode, Node.CONNECTION_DEFAULT_TYPE);
    new io.automatiko.engine.workflow.process.core.impl.ConnectionImpl(compositeNode, Node.CONNECTION_DEFAULT_TYPE, endNode, Node.CONNECTION_DEFAULT_TYPE);
    ProcessValidationError[] errors = validator.validateProcess(process);
    assertNotNull(errors);
    assertEquals(1, errors.length);
    assertEquals("Node 'CompositeNode' [3] Composite has no start node defined.", errors[0].getMessage());
}
Also used : StartNode(io.automatiko.engine.workflow.process.core.node.StartNode) CompositeNode(io.automatiko.engine.workflow.process.core.node.CompositeNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Example 5 with ProcessValidationError

use of io.automatiko.engine.workflow.base.core.validation.ProcessValidationError in project automatiko-engine by automatiko-io.

the class RuleFlowProcessValidatorTest method testDynamicNodeValidationInNotDynamicProcess.

@Test
void testDynamicNodeValidationInNotDynamicProcess() {
    ExecutableProcess process = new ExecutableProcess();
    process.setId("org.company.core.process");
    process.setName("Dynamic Node Process");
    process.setPackageName("org.mycomp.myprocess");
    process.setDynamic(false);
    DynamicNode dynamicNode = new DynamicNode();
    dynamicNode.setName("MyDynamicNode");
    dynamicNode.setId(1);
    dynamicNode.setAutoComplete(false);
    // empty completion expression to trigger validation error
    process.addNode(dynamicNode);
    ProcessValidationError[] errors = validator.validateProcess(process);
    assertNotNull(errors);
    // in non-dynamic processes all check should be triggered
    // they should also include process level checks (start node, end node etc)
    assertEquals(6, errors.length);
    assertEquals("Process has no start node.", errors[0].getMessage());
    assertEquals("Process has no end node.", errors[1].getMessage());
    assertEquals("Node 'MyDynamicNode' [1] Dynamic has no incoming connection", errors[2].getMessage());
    assertEquals("Node 'MyDynamicNode' [1] Dynamic has no outgoing connection", errors[3].getMessage());
    assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set", errors[4].getMessage());
    assertEquals("Node 'MyDynamicNode' [1] Has no connection to the start node.", errors[5].getMessage());
}
Also used : ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) DynamicNode(io.automatiko.engine.workflow.process.core.node.DynamicNode) ProcessValidationError(io.automatiko.engine.workflow.base.core.validation.ProcessValidationError) Test(org.junit.jupiter.api.Test)

Aggregations

ProcessValidationError (io.automatiko.engine.workflow.base.core.validation.ProcessValidationError)7 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)5 Test (org.junit.jupiter.api.Test)5 DynamicNode (io.automatiko.engine.workflow.process.core.node.DynamicNode)2 ProcessValidationErrorImpl (io.automatiko.engine.workflow.base.core.validation.impl.ProcessValidationErrorImpl)1 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)1 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)1 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)1 ArrayList (java.util.ArrayList)1