Search in sources :

Example 1 with KogitoNodeInstanceContainer

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);
}
Also used : TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) BeforeMatchFiredEvent(org.kie.api.event.rule.BeforeMatchFiredEvent) Address(org.jbpm.bpmn2.objects.Address) Account(org.jbpm.bpmn2.objects.Account) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) HelloService(org.jbpm.bpmn2.objects.HelloService) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) Disabled(org.junit.jupiter.api.Disabled) DefaultKogitoProcessEventListener(org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener) Assignment(org.jbpm.workflow.core.node.Assignment) KogitoNodeInstanceContainer(org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer) BigDecimal(java.math.BigDecimal) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) SystemOutWorkItemHandler(org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler) Map(java.util.Map) ProcessBuildContext(org.jbpm.process.builder.ProcessBuildContext) ProcessDialectRegistry(org.jbpm.process.builder.dialect.ProcessDialectRegistry) ProcessVariableChangedEvent(org.kie.api.event.process.ProcessVariableChangedEvent) ActionBuilder(org.jbpm.process.builder.ActionBuilder) ProcessClassBuilder(org.jbpm.process.builder.ProcessClassBuilder) RuleAwareProcessEventListener(org.jbpm.process.instance.event.listeners.RuleAwareProcessEventListener) DoNothingWorkItemHandler(org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler) Process(org.kie.api.definition.process.Process) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) SendTaskHandler(org.jbpm.bpmn2.handler.SendTaskHandler) VariableScope(org.jbpm.process.core.context.variable.VariableScope) Test(org.junit.jupiter.api.Test) List(java.util.List) ProcessNodeTriggeredEvent(org.kie.api.event.process.ProcessNodeTriggeredEvent) Assertions.fail(org.assertj.core.api.Assertions.fail) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Person(org.jbpm.bpmn2.objects.Person) KogitoWorkItemManager(org.kie.kogito.internal.process.runtime.KogitoWorkItemManager) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) NodeContainer(org.kie.api.definition.process.NodeContainer) DynamicUtils(org.jbpm.workflow.instance.node.DynamicUtils) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition) WorkflowRuntimeException(org.jbpm.workflow.instance.WorkflowRuntimeException) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) AssignmentBuilder(org.jbpm.process.builder.AssignmentBuilder) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) NodeInstance(org.kie.api.runtime.process.NodeInstance) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) HashMap(java.util.HashMap) KogitoProcessRuntime(org.kie.kogito.internal.process.runtime.KogitoProcessRuntime) ExecutableCommand(org.kie.api.command.ExecutableCommand) TestWorkItemHandler(org.jbpm.bpmn2.objects.TestWorkItemHandler) ArrayList(java.util.ArrayList) TriggerRulesEventListener(org.jbpm.process.instance.event.listeners.TriggerRulesEventListener) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) AfterMatchFiredEvent(org.kie.api.event.rule.AfterMatchFiredEvent) KogitoWorkflowProcessInstance(org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance) ServiceTaskHandler(org.jbpm.bpmn2.handler.ServiceTaskHandler) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) DataTransformer(org.kie.api.runtime.process.DataTransformer) ActionNode(org.jbpm.workflow.core.node.ActionNode) ReturnValueEvaluatorBuilder(org.jbpm.process.builder.ReturnValueEvaluatorBuilder) RequirePersistence(org.jbpm.bpmn2.test.RequirePersistence) AgendaEventListener(org.kie.api.event.rule.AgendaEventListener) PackageBuildContext(org.drools.compiler.rule.builder.PackageBuildContext) DataTransformerRegistry(org.jbpm.process.core.impl.DataTransformerRegistry) Node(org.kie.api.definition.process.Node) NodeLeftCountDownProcessEventListener(org.jbpm.test.util.NodeLeftCountDownProcessEventListener) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) MatchCreatedEvent(org.kie.api.event.rule.MatchCreatedEvent) Collections(java.util.Collections) Timeout(org.junit.jupiter.api.Timeout) ProcessStartedEvent(org.kie.api.event.process.ProcessStartedEvent) MatchCancelledEvent(org.kie.api.event.rule.MatchCancelledEvent) ReceiveTaskHandler(org.jbpm.bpmn2.handler.ReceiveTaskHandler) InternalKogitoWorkItem(org.kie.kogito.process.workitems.InternalKogitoWorkItem) KogitoProcessInstance(org.kie.kogito.internal.process.runtime.KogitoProcessInstance) KogitoWorkItem(org.kie.kogito.internal.process.runtime.KogitoWorkItem) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) Test(org.junit.jupiter.api.Test)

Aggregations

BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 PackageBuildContext (org.drools.compiler.rule.builder.PackageBuildContext)1 ReceiveTaskHandler (org.jbpm.bpmn2.handler.ReceiveTaskHandler)1 SendTaskHandler (org.jbpm.bpmn2.handler.SendTaskHandler)1 ServiceTaskHandler (org.jbpm.bpmn2.handler.ServiceTaskHandler)1 Account (org.jbpm.bpmn2.objects.Account)1 Address (org.jbpm.bpmn2.objects.Address)1 HelloService (org.jbpm.bpmn2.objects.HelloService)1 Person (org.jbpm.bpmn2.objects.Person)1 TestWorkItemHandler (org.jbpm.bpmn2.objects.TestWorkItemHandler)1 RequirePersistence (org.jbpm.bpmn2.test.RequirePersistence)1 ActionBuilder (org.jbpm.process.builder.ActionBuilder)1 AssignmentBuilder (org.jbpm.process.builder.AssignmentBuilder)1