Search in sources :

Example 81 with RuleFlowProcess

use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.

the class MapPersistenceTest method processWithNotNullStartDateTest.

@Test
public void processWithNotNullStartDateTest() {
    String processId = "signalProcessTest";
    String eventType = "myEvent";
    RuleFlowProcess process = ProcessCreatorForHelp.newSimpleEventProcess(processId, eventType);
    KieBase kbase = createKieBase(process);
    StatefulKnowledgeSession crmPersistentSession = createSession(kbase);
    RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) crmPersistentSession.startProcess(processId);
    InternalKnowledgeRuntime kruntime = processInstance.getKnowledgeRuntime();
    Assert.assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    ProcessInstanceInfo processInstanceInfo = new ProcessInstanceInfo(processInstance);
    processInstance = (RuleFlowProcessInstance) processInstanceInfo.getProcessInstance(kruntime, crmPersistentSession.getEnvironment());
    Assert.assertNotNull(processInstance.getStartDate());
    Assert.assertEquals(processInstance.getStartDate(), processInstanceInfo.getStartDate());
}
Also used : InternalKnowledgeRuntime(org.drools.core.common.InternalKnowledgeRuntime) ProcessInstanceInfo(org.jbpm.persistence.processinstance.ProcessInstanceInfo) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) KieBase(org.kie.api.KieBase) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 82 with RuleFlowProcess

use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.

the class MapPersistenceTest method multipleSessionsWithSameProcessAndDifferentIdTest.

@Test
public void multipleSessionsWithSameProcessAndDifferentIdTest() {
    String processId = "signalProcessTest";
    String eventType = "myEvent";
    RuleFlowProcess process1 = ProcessCreatorForHelp.newSimpleEventProcess(processId, eventType);
    RuleFlowProcess process2 = ProcessCreatorForHelp.newSimpleEventProcess(processId, eventType);
    KieBase kbase1 = createKieBase(process1);
    KieBase kbase2 = createKieBase(process2);
    StatefulKnowledgeSession ksession1 = createSession(kbase1);
    StatefulKnowledgeSession ksession2 = createSession(kbase2);
    Assert.assertNotSame(ksession1.getIdentifier(), ksession2.getIdentifier());
    Long processInstance1Id = ksession1.startProcess(processId).getId();
    Long processInstance2Id = ksession2.startProcess(processId).getId();
    Assert.assertNotSame(processInstance1Id, processInstance2Id);
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) KieBase(org.kie.api.KieBase) StatefulKnowledgeSession(org.kie.internal.runtime.StatefulKnowledgeSession) Test(org.junit.Test) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest)

Example 83 with RuleFlowProcess

use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.

the class ProcessCreatorForHelp method newSimpleEventProcess.

public static RuleFlowProcess newSimpleEventProcess(String processId, String eventType) {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(processId);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    EventNode eventNode = new EventNode();
    eventNode.setName("EventNode");
    eventNode.setId(2);
    eventNode.setScope("external");
    EventTypeFilter eventFilter = new EventTypeFilter();
    eventFilter.setType(eventType);
    eventNode.addEventFilter(eventFilter);
    EndNode endNode = new EndNode();
    endNode.setName("End");
    endNode.setId(3);
    connect(startNode, eventNode);
    connect(eventNode, endNode);
    process.addNode(startNode);
    process.addNode(eventNode);
    process.addNode(endNode);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter)

Example 84 with RuleFlowProcess

use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.

the class ProcessCreatorForHelp method newProcessWithOneVariableAndOneWork.

public static RuleFlowProcess newProcessWithOneVariableAndOneWork(String processId, String variableName, String workName) {
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(processId);
    List<Variable> variables = new ArrayList<Variable>();
    Variable variable = new Variable();
    variable.setName(variableName);
    ObjectDataType extendingSerializableDataType = new ObjectDataType();
    extendingSerializableDataType.setClassName(Person.class.getName());
    variable.setType(extendingSerializableDataType);
    variables.add(variable);
    process.getVariableScope().setVariables(variables);
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    WorkItemNode workItemNode = new WorkItemNode();
    workItemNode.setName("workItemNode");
    workItemNode.setId(2);
    Work work = new WorkImpl();
    work.setName(workName);
    workItemNode.setWork(work);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(4);
    connect(startNode, workItemNode);
    connect(workItemNode, endNode);
    process.addNode(startNode);
    process.addNode(workItemNode);
    process.addNode(endNode);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Variable(org.jbpm.process.core.context.variable.Variable) ArrayList(java.util.ArrayList) Work(org.jbpm.process.core.Work) WorkImpl(org.jbpm.process.core.impl.WorkImpl) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) Person(org.jbpm.persistence.session.objects.Person)

Example 85 with RuleFlowProcess

use of org.jbpm.ruleflow.core.RuleFlowProcess in project jbpm by kiegroup.

the class ProcessCreatorForHelp method newShortestProcess.

public static RuleFlowProcess newShortestProcess(String processId) {
    StartNode startNode = new StartNode();
    startNode.setName("Start");
    startNode.setId(1);
    EndNode endNode = new EndNode();
    endNode.setName("EndNode");
    endNode.setId(2);
    connect(startNode, endNode);
    RuleFlowProcess process = new RuleFlowProcess();
    process.setId(processId);
    process.addNode(startNode);
    process.addNode(endNode);
    return process;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess)

Aggregations

RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)85 Test (org.junit.Test)47 ArrayList (java.util.ArrayList)38 StartNode (org.jbpm.workflow.core.node.StartNode)38 EndNode (org.jbpm.workflow.core.node.EndNode)37 ActionNode (org.jbpm.workflow.core.node.ActionNode)33 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)32 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)24 KieSession (org.kie.api.runtime.KieSession)20 DroolsAction (org.jbpm.workflow.core.DroolsAction)19 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)19 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)19 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)17 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)17 Variable (org.jbpm.process.core.context.variable.Variable)16 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)16 Action (org.jbpm.process.instance.impl.Action)16 CompositeNode (org.jbpm.workflow.core.node.CompositeNode)16 ProcessContext (org.kie.api.runtime.process.ProcessContext)16 KieBase (org.kie.api.KieBase)15