Skip to content

Commit

Permalink
V7 process test migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhitocode committed May 10, 2024
1 parent 218e3dd commit 1400431
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;

import org.drools.compiler.rule.builder.PackageBuildContext;
import org.jbpm.bpmn2.flow.*;
import org.jbpm.bpmn2.handler.ReceiveTaskHandler;
import org.jbpm.bpmn2.handler.SendTaskHandler;
import org.jbpm.bpmn2.handler.ServiceTaskHandler;
Expand All @@ -36,6 +37,8 @@
import org.jbpm.bpmn2.objects.TestWorkItemHandler;
import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsModel;
import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsProcess;
import org.jbpm.bpmn2.task.SendTaskModel;
import org.jbpm.bpmn2.task.SendTaskProcess;
import org.jbpm.bpmn2.test.RequirePersistence;
import org.jbpm.process.builder.ActionBuilder;
import org.jbpm.process.builder.AssignmentBuilder;
Expand Down Expand Up @@ -99,30 +102,42 @@ public class ActivityTest extends JbpmBpmn2TestCase {

@Test
public void testMinimalProcess() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcess.bpmn2");
KogitoProcessInstance processInstance = kruntime.startProcess("Minimal");
assertProcessInstanceCompleted(processInstance);
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<MinimalModel> minimalProcess = MinimalProcess.newProcess(app);
MinimalModel model = minimalProcess.createModel();
org.kie.kogito.process.ProcessInstance<MinimalModel> instance = minimalProcess.createInstance(model);
instance.start();
assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
}

@Test
public void testMinimalProcessImplicit() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessImplicit.bpmn2");
KogitoProcessInstance processInstance = kruntime.startProcess("MinimalImplicit");
assertProcessInstanceCompleted(processInstance);
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<MinimalImplicitModel> minimalImplicitProcess = MinimalImplicitProcess.newProcess(app);
MinimalImplicitModel model = minimalImplicitProcess.createModel();
ProcessInstance<MinimalImplicitModel> instance = minimalImplicitProcess.createInstance(model);
instance.start();
assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}

@Test
public void testMinimalProcessWithGraphical() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithGraphical.bpmn2");
KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithGraphical");
assertProcessInstanceCompleted(processInstance);
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<MinimalWithGraphicalModel> minimalwithgraphicalprocess = MinimalWithGraphicalProcess.newProcess(app);
MinimalWithGraphicalModel model = minimalwithgraphicalprocess.createModel();
ProcessInstance<MinimalWithGraphicalModel> instance = minimalwithgraphicalprocess.createInstance(model);
instance.start();
assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}

@Test
public void testMinimalProcessWithDIGraphical() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-MinimalProcessWithDIGraphical.bpmn2");
KogitoProcessInstance processInstance = kruntime.startProcess("MinimalWithDIGraphical");
assertProcessInstanceCompleted(processInstance);
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<MinimalWithDIGraphicalModel> minimalwithdigraphicalprocess = MinimalWithDIGraphicalProcess.newProcess(app);
MinimalWithDIGraphicalModel model = minimalwithdigraphicalprocess.createModel();
ProcessInstance<MinimalWithDIGraphicalModel> instance = minimalwithdigraphicalprocess.createInstance(model);
instance.start();
assertThat(instance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}

@Test
Expand Down Expand Up @@ -828,15 +843,14 @@ public void executeWorkItem(KogitoWorkItem workItem, KogitoWorkItemManager manag

@Test
public void testSendTask() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/task/BPMN2-SendTask.bpmn2");

kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Send Task",
new SendTaskHandler());
Map<String, Object> params = new HashMap<>();
params.put("s", "john");
KogitoWorkflowProcessInstance processInstance = (KogitoWorkflowProcessInstance) kruntime
.startProcess("SendTask", params);
assertProcessInstanceFinished(processInstance, kruntime);
Application app = ProcessTestHelper.newApplication();
ProcessTestHelper.registerHandler(app, "Send Task", new SendTaskHandler());
org.kie.kogito.process.Process<SendTaskModel> processDefinition = SendTaskProcess.newProcess(app);
SendTaskModel model = processDefinition.createModel();
model.setS("john");
org.kie.kogito.process.ProcessInstance<SendTaskModel> instance = processDefinition.createInstance(model);
instance.start();
assertThat(instance.status()).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
}

@Test
Expand Down Expand Up @@ -936,6 +950,7 @@ public void testBusinessRuleTaskWithContionalEvent() throws Exception {
assertThat(list).hasSize(1);
}

// The model does not have set myVar
@Test
public void testScriptTaskWithVariableByName() throws Exception {
Map<String, Object> params = new HashMap<>();
Expand Down

0 comments on commit 1400431

Please sign in to comment.