use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class ProcessHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String id = attrs.getValue("id");
final String name = attrs.getValue("name");
final String version = attrs.getValue("version");
final String type = attrs.getValue("type");
final String packageName = attrs.getValue("package-name");
final String routerLayout = attrs.getValue("routerLayout");
RuleFlowProcess process = new RuleFlowProcess();
process.setId(id);
process.setName(name);
process.setVersion(version);
process.setType(type);
process.setPackageName(packageName);
if (routerLayout != null) {
process.setMetaData("routerLayout", new Integer(routerLayout));
}
((ProcessBuildData) parser.getData()).addProcess(process);
return process;
}
use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class StartNodeInstanceTest method testStartNode.
@Test
public void testStartNode() {
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KieSession ksession = kbase.newKieSession();
MockNode mockNode = new MockNode();
MockNodeInstanceFactory mockNodeFactory = new MockNodeInstanceFactory(new MockNodeInstance(mockNode));
NodeInstanceFactoryRegistry.getInstance(ksession.getEnvironment()).register(mockNode.getClass(), mockNodeFactory);
RuleFlowProcess process = new RuleFlowProcess();
StartNode startNode = new StartNode();
startNode.setId(1);
startNode.setName("start node");
mockNode.setId(2);
new ConnectionImpl(startNode, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, mockNode, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
process.addNode(startNode);
process.addNode(mockNode);
RuleFlowProcessInstance processInstance = new RuleFlowProcessInstance();
processInstance.setProcess(process);
processInstance.setKnowledgeRuntime((InternalKnowledgeRuntime) ksession);
assertEquals(ProcessInstance.STATE_PENDING, processInstance.getState());
processInstance.start();
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
MockNodeInstance mockNodeInstance = mockNodeFactory.getMockNodeInstance();
List<NodeInstance> triggeredBy = mockNodeInstance.getTriggers().get(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
assertNotNull(triggeredBy);
assertEquals(1, triggeredBy.size());
assertSame(startNode.getId(), triggeredBy.get(0).getNodeId());
}
use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class RuleFlowProcessValidatorTest method testDynamicNodeValidationInNotDynamicProcess.
@Test
public void testDynamicNodeValidationInNotDynamicProcess() throws Exception {
RuleFlowProcess process = new RuleFlowProcess();
process.setId("org.drools.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
dynamicNode.setCompletionExpression("");
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());
}
use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class RuleFlowProcessValidatorTest method testDynamicNodeValidationInDynamicProcess.
@Test
public void testDynamicNodeValidationInDynamicProcess() throws Exception {
RuleFlowProcess process = new RuleFlowProcess();
process.setId("org.drools.core.process");
process.setName("Dynamic Node Process");
process.setPackageName("org.mycomp.myprocess");
process.setDynamic(true);
DynamicNode dynamicNode = new DynamicNode();
dynamicNode.setName("MyDynamicNode");
dynamicNode.setId(1);
dynamicNode.setAutoComplete(false);
dynamicNode.setCompletionExpression("completion-expression");
process.addNode(dynamicNode);
ProcessValidationError[] errors = validator.validateProcess(process);
assertNotNull(errors);
// if dynamic process no longer triggering incoming / outgoing connection errors for dynamic nodes
assertEquals(0, errors.length);
// empty completion expression to trigger validation error
process.removeNode(dynamicNode);
DynamicNode dynamicNode2 = new DynamicNode();
dynamicNode2.setName("MyDynamicNode");
dynamicNode2.setId(1);
dynamicNode2.setAutoComplete(false);
dynamicNode2.setCompletionExpression("");
process.addNode(dynamicNode2);
ProcessValidationError[] errors2 = validator.validateProcess(process);
assertNotNull(errors2);
// autocomplete set to false and empty completion condition triggers error
assertEquals(1, errors2.length);
assertEquals("Node 'MyDynamicNode' [1] Dynamic has no completion condition set", errors2[0].getMessage());
}
use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.
the class RuleFlowProcessValidatorTest method testNoPackageName.
@Test
public void testNoPackageName() throws Exception {
RuleFlowProcess process = new RuleFlowProcess();
process.setId("org.drools.core.process");
process.setName("No Package Name Process");
process.setDynamic(true);
ProcessValidationError[] errors = validator.validateProcess(process);
assertNotNull(errors);
assertEquals(0, errors.length);
}
Aggregations