Skip to content

Commit

Permalink
Revert "[incubator-kie-issues-1131] Process test migration from v7 le…
Browse files Browse the repository at this point in the history
…gacy runtime to code generation (apache#3520)"

This reverts commit 3432985.
  • Loading branch information
Abhitocode committed Jun 7, 2024
1 parent 3432985 commit 9da73da
Showing 1 changed file with 62 additions and 80 deletions.
142 changes: 62 additions & 80 deletions jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/ActivityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import org.jbpm.bpmn2.activity.ScriptTaskWithIOProcess;
import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataModel;
import org.jbpm.bpmn2.activity.UserTaskWithSimulationMetaDataProcess;
import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessModel;
import org.jbpm.bpmn2.adhoc.SubProcessInAdHocProcessProcess;
import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalModel;
import org.jbpm.bpmn2.flow.CompositeWithDIGraphicalProcess;
import org.jbpm.bpmn2.flow.MinimalImplicitModel;
Expand All @@ -52,8 +50,6 @@
import org.jbpm.bpmn2.flow.ProcessWithVariableNameProcess;
import org.jbpm.bpmn2.flow.UserTaskModel;
import org.jbpm.bpmn2.flow.UserTaskProcess;
import org.jbpm.bpmn2.flow.XORSameTargetModel;
import org.jbpm.bpmn2.flow.XORSameTargetProcess;
import org.jbpm.bpmn2.handler.ReceiveTaskHandler;
import org.jbpm.bpmn2.handler.SendTaskHandler;
import org.jbpm.bpmn2.handler.ServiceTaskHandler;
Expand All @@ -62,19 +58,11 @@
import org.jbpm.bpmn2.objects.HelloService;
import org.jbpm.bpmn2.objects.Person;
import org.jbpm.bpmn2.objects.TestWorkItemHandler;
import org.jbpm.bpmn2.subprocess.AssignmentProcessModel;
import org.jbpm.bpmn2.subprocess.AssignmentProcessProcess;
import org.jbpm.bpmn2.subprocess.AssignmentSubProcessModel;
import org.jbpm.bpmn2.subprocess.AssignmentSubProcessProcess;
import org.jbpm.bpmn2.subprocess.CallActivityModel;
import org.jbpm.bpmn2.subprocess.CallActivityProcess;
import org.jbpm.bpmn2.subprocess.CallActivitySubProcessProcess;
import org.jbpm.bpmn2.subprocess.CallActivityWithIOexpressionModel;
import org.jbpm.bpmn2.subprocess.CallActivityWithIOexpressionProcess;
import org.jbpm.bpmn2.subprocess.InputMappingUsingValueModel;
import org.jbpm.bpmn2.subprocess.InputMappingUsingValueProcess;
import org.jbpm.bpmn2.subprocess.MainGroupAssignmentModel;
import org.jbpm.bpmn2.subprocess.MainGroupAssignmentProcess;
import org.jbpm.bpmn2.subprocess.SingleTaskWithVarDefModel;
import org.jbpm.bpmn2.subprocess.SingleTaskWithVarDefProcess;
import org.jbpm.bpmn2.subprocess.SubProcessWithEntryExitScriptsModel;
Expand All @@ -83,8 +71,6 @@
import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcess;
import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcessScopeModel;
import org.jbpm.bpmn2.subprocess.SubProcessWithTerminateEndEventProcessScopeProcess;
import org.jbpm.bpmn2.subprocess.SubprocessGroupAssignmentModel;
import org.jbpm.bpmn2.subprocess.SubprocessGroupAssignmentProcess;
import org.jbpm.bpmn2.task.ReceiveTaskModel;
import org.jbpm.bpmn2.task.ReceiveTaskProcess;
import org.jbpm.bpmn2.task.SendTaskModel;
Expand Down Expand Up @@ -1407,37 +1393,36 @@ public void testMultipleBusinessRuleTaskWithDataInputsWithPersistence()
}

@Test
public void testSubProcessInAdHocProcess() {
public void testSubProcessInAdHocProcess() throws Exception {
// JBPM-5374
Application app = ProcessTestHelper.newApplication();
kruntime = createKogitoProcessRuntime(
"org/jbpm/bpmn2/adhoc/BPMN2-SubProcessInAdHocProcess.bpmn2");

TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
org.kie.kogito.process.Process<SubProcessInAdHocProcessModel> processDefinition = SubProcessInAdHocProcessProcess.newProcess(app);
SubProcessInAdHocProcessModel model = processDefinition.createModel();
org.kie.kogito.process.ProcessInstance<SubProcessInAdHocProcessModel> instance = processDefinition.createInstance(model);
instance.start();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);

Map<String, Object> parameters = new HashMap<>();
KogitoProcessInstance processInstance = kruntime.startProcess("SubProcessInAdHocProcess", parameters);
assertProcessInstanceActive(processInstance);

kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);

assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE);
org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
instance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
assertProcessInstanceFinished(processInstance, kruntime);
}

@Test
public void testCallActivityWithDataAssignment() {
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<AssignmentSubProcessModel> assignmentSubProcessProcess = AssignmentSubProcessProcess.newProcess(app);
AssignmentSubProcessModel assignmentSubProcessModel = assignmentSubProcessProcess.createModel();
org.kie.kogito.process.ProcessInstance<AssignmentSubProcessModel> assignmentSubProcessInstance = assignmentSubProcessProcess.createInstance(assignmentSubProcessModel);
org.kie.kogito.process.Process<AssignmentProcessModel> processDefinition = AssignmentProcessProcess.newProcess(app);
AssignmentProcessModel model = processDefinition.createModel();
model.setName("oldValue");
org.kie.kogito.process.ProcessInstance<AssignmentProcessModel> instance = processDefinition.createInstance(model);
instance.start();
public void testCallActivityWithDataAssignment() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-AssignmentProcess.bpmn2",
"org/jbpm/bpmn2/subprocess/BPMN2-AssignmentSubProcess.bpmn2");

assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
assertThat(instance.variables().getMessage()).isEqualTo("Hello Genworth welcome to jBPMS!");
Map<String, Object> params = new HashMap<>();
params.put("name", "oldValue");
KogitoProcessInstance processInstance = kruntime.startProcess("AssignmentProcess", params);
assertProcessInstanceCompleted(processInstance);
assertThat(((KogitoWorkflowProcessInstance) processInstance).getVariable("message")).isEqualTo("Hello Genworth welcome to jBPMS!");
}

@Test
Expand Down Expand Up @@ -1629,20 +1614,18 @@ public void testBusinessRuleTaskException() throws Exception {
}

@Test
public void testXORWithSameTargetProcess() {
Application app = ProcessTestHelper.newApplication();
org.kie.kogito.process.Process<XORSameTargetModel> processDefinition = XORSameTargetProcess.newProcess(app);
XORSameTargetModel model = processDefinition.createModel();
model.setChoice(1);
org.kie.kogito.process.ProcessInstance<XORSameTargetModel> instance = processDefinition.createInstance(model);
instance.start();
assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
processDefinition = XORSameTargetProcess.newProcess(app);
model = processDefinition.createModel();
model.setChoice(2);
instance = processDefinition.createInstance(model);
instance.start();
assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
public void testXORWithSameTargetProcess() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/flow/BPMN2-XORSameTarget.bpmn2");

Map<String, Object> params = new HashMap<>();
params.put("choice", 1);
KogitoProcessInstance processInstance = kruntime.startProcess("XORSameTarget", params);
assertProcessInstanceCompleted(processInstance);

params = new HashMap<>();
params.put("choice", 2);
processInstance = kruntime.startProcess("XORSameTarget", params);
assertProcessInstanceCompleted(processInstance);
}

@Test
Expand All @@ -1668,48 +1651,47 @@ public void testUserTaskWithExpressionsForIO() throws Exception {
}

@Test
public void testCallActivitykWithExpressionsForIO() {
Application app = ProcessTestHelper.newApplication();
public void testCallActivitykWithExpressionsForIO() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-CallActivityWithIOexpression.bpmn2",
"org/jbpm/bpmn2/subprocess/BPMN2-CallActivitySubProcess.bpmn2");

TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
CallActivitySubProcessProcess.newProcess(app);
org.kie.kogito.process.Process<CallActivityWithIOexpressionModel> processDefinition = CallActivityWithIOexpressionProcess.newProcess(app);
CallActivityWithIOexpressionModel model = processDefinition.createModel();
model.setPerson(new Person("john"));
org.kie.kogito.process.ProcessInstance<CallActivityWithIOexpressionModel> instance = processDefinition.createInstance(model);
instance.start();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
Map<String, Object> params = new HashMap<>();
params.put("person", new Person("john"));
KogitoProcessInstance processInstance = kruntime.startProcess("CallActivityWithIOexpression", params);
assertProcessInstanceActive(processInstance);

assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE);
Person person = instance.variables().getPerson();
Person person = (Person) processInstance.getVariables().get("person");
assertThat(person.getName()).isEqualTo("new value");

org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertThat(workItem).isNotNull();
assertThat(workItem.getParameter("ActorId")).isEqualTo("krisv");
instance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);

assertProcessInstanceFinished(processInstance, kruntime);
}

@Test
public void testCallSubprocessWithGroup() {
Application app = ProcessTestHelper.newApplication();
public void testCallSubprocessWithGroup() throws Exception {
kruntime = createKogitoProcessRuntime("org/jbpm/bpmn2/subprocess/BPMN2-MainGroupAssignment.bpmn2",
"org/jbpm/bpmn2/subprocess/BPMN2-SubprocessGroupAssignment.bpmn2");

TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
ProcessTestHelper.registerHandler(app, "Human Task", workItemHandler);
org.kie.kogito.process.Process<SubprocessGroupAssignmentModel> subprocessGroupAssignmentProcess = SubprocessGroupAssignmentProcess.newProcess(app);
SubprocessGroupAssignmentModel subprocessGroupAssignmentModel = subprocessGroupAssignmentProcess.createModel();
ProcessInstance<SubprocessGroupAssignmentModel> subprocessGroupAssignmentProcessInstance = subprocessGroupAssignmentProcess.createInstance(subprocessGroupAssignmentModel);
org.kie.kogito.process.Process<MainGroupAssignmentModel> processDefinition = MainGroupAssignmentProcess.newProcess(app);
MainGroupAssignmentModel model = processDefinition.createModel();
org.kie.kogito.process.ProcessInstance<MainGroupAssignmentModel> instance = processDefinition.createInstance(model);
instance.start();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);

KogitoProcessInstance processInstance = kruntime.startProcess("MainGroupAssignment");
assertProcessInstanceActive(processInstance);

assertThat(instance).extracting(ProcessInstance::status).isEqualTo(ProcessInstance.STATE_ACTIVE);
List<org.kie.kogito.internal.process.runtime.KogitoWorkItem> workItems = workItemHandler.getWorkItems();
workItems.forEach(workItem -> {
assertThat(workItem).isNotNull();
assertThat(workItem.getParameter("GroupId")).isEqualTo("GRUPA TESTOWA");
subprocessGroupAssignmentProcessInstance.completeWorkItem(workItem.getStringId(), Collections.emptyMap());
});
assertThat(instance).extracting(ProcessInstance::status).isEqualTo(org.kie.kogito.process.ProcessInstance.STATE_COMPLETED);
for (org.kie.kogito.internal.process.runtime.KogitoWorkItem item : workItems) {
assertThat(item).isNotNull();
assertThat(item.getParameter("GroupId")).isEqualTo("GRUPA TESTOWA");
kruntime.getKogitoWorkItemManager().completeWorkItem(item.getStringId(), null);
}

assertProcessInstanceFinished(processInstance, kruntime);
}

@Test
Expand Down

0 comments on commit 9da73da

Please sign in to comment.