use of org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer in project kogito-runtimes by kiegroup.
the class ActivityTest method testUserTaskVerifyParameters.
@Test
public void testUserTaskVerifyParameters() throws Exception {
kruntime = createKogitoProcessRuntime("BPMN2-UserTask.bpmn2");
kruntime.getKieSession().getEnvironment().set("deploymentId", "test-deployment-id");
TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human Task", workItemHandler);
KogitoProcessInstance processInstance = kruntime.startProcess("UserTask");
assertEquals(KogitoProcessInstance.STATE_ACTIVE, processInstance.getState());
org.kie.kogito.internal.process.runtime.KogitoWorkItem workItem = workItemHandler.getWorkItem();
assertNotNull(workItem);
assertEquals("john", workItem.getParameter("ActorId"));
final String pId = processInstance.getStringId();
kruntime.getKieSession().execute((ExecutableCommand<Void>) context -> {
KogitoProcessInstance processInstance1 = kruntime.getProcessInstance(pId);
assertNotNull(processInstance1);
NodeInstance nodeInstance = ((KogitoNodeInstanceContainer) processInstance1).getNodeInstance(((InternalKogitoWorkItem) workItem).getNodeInstanceStringId());
assertNotNull(nodeInstance);
assertTrue(nodeInstance instanceof WorkItemNodeInstance);
String deploymentId = ((WorkItemNodeInstance) nodeInstance).getWorkItem().getDeploymentId();
String nodeInstanceId = ((WorkItemNodeInstance) nodeInstance).getWorkItem().getNodeInstanceStringId();
long nodeId = ((WorkItemNodeInstance) nodeInstance).getWorkItem().getNodeId();
assertEquals(((InternalKogitoWorkItem) workItem).getDeploymentId(), deploymentId);
assertEquals(((InternalKogitoWorkItem) workItem).getNodeId(), nodeId);
assertEquals(((InternalKogitoWorkItem) workItem).getNodeInstanceStringId(), nodeInstanceId);
return null;
});
kruntime.getKogitoWorkItemManager().completeWorkItem(workItem.getStringId(), null);
assertProcessInstanceFinished(processInstance, kruntime);
}
Aggregations