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()]);
}
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);
}
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);
}
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());
}
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());
}
Aggregations