Search in sources :

Example 6 with ProcessValidationError

use of org.jbpm.process.core.validation.ProcessValidationError in project jbpm by kiegroup.

the class RuleFlowProcessValidator method validateProcess.

public ProcessValidationError[] validateProcess(final RuleFlowProcess process) {
    final List<ProcessValidationError> errors = new ArrayList<ProcessValidationError>();
    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(org.jbpm.process.core.validation.impl.ProcessValidationErrorImpl) ProcessValidationError(org.jbpm.process.core.validation.ProcessValidationError)

Example 7 with ProcessValidationError

use of org.jbpm.process.core.validation.ProcessValidationError in project jbpm by kiegroup.

the class RuleFlowProcessValidatorTest method testEmptyPackageName.

@Test
public void testEmptyPackageName() throws Exception {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId("org.drools.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 : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ProcessValidationError(org.jbpm.process.core.validation.ProcessValidationError) Test(org.junit.Test)

Aggregations

ProcessValidationError (org.jbpm.process.core.validation.ProcessValidationError)7 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)4 Test (org.junit.Test)4 StringReader (java.io.StringReader)2 ProcessValidator (org.jbpm.process.core.validation.ProcessValidator)2 DynamicNode (org.jbpm.workflow.core.node.DynamicNode)2 Process (org.kie.api.definition.process.Process)2 Resource (org.kie.api.io.Resource)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Dialect (org.drools.compiler.compiler.Dialect)1 DialectCompiletimeRegistry (org.drools.compiler.compiler.DialectCompiletimeRegistry)1 DroolsParserException (org.drools.compiler.compiler.DroolsParserException)1 DuplicateProcess (org.drools.compiler.compiler.DuplicateProcess)1 PackageRegistry (org.drools.compiler.compiler.PackageRegistry)1 ParserError (org.drools.compiler.compiler.ParserError)1 ProcessDescr (org.drools.compiler.lang.descr.ProcessDescr)1 JavaDialect (org.drools.compiler.rule.builder.dialect.java.JavaDialect)1 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)1 ByteArrayResource (org.drools.core.io.impl.ByteArrayResource)1