Search in sources :

Example 16 with WorkItemNodeInstance

use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.

the class RuntimeDataServiceEJBIntegrationTest method testGetTaskByWorkItemId.

@Test
public void testGetTaskByWorkItemId() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    UserTaskInstanceDesc userTask = runtimeDataService.getTaskByWorkItemId(workItemId);
    assertNotNull(userTask);
    assertEquals(processInstanceId, userTask.getProcessInstanceId());
    assertEquals("Write a Document", userTask.getName());
}
Also used : WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) Test(org.junit.Test)

Example 17 with WorkItemNodeInstance

use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.

the class RuntimeDataServiceEJBIntegrationTest method testGetTaskAudit.

@Test
public void testGetTaskAudit() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    List<AuditTask> auditTasks = runtimeDataService.getAllAuditTask("salaboy", new QueryFilter(0, 10));
    assertNotNull(auditTasks);
    assertEquals(1, auditTasks.size());
    assertEquals("Write a Document", auditTasks.get(0).getName());
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) AuditTask(org.kie.internal.task.api.AuditTask) Test(org.junit.Test)

Example 18 with WorkItemNodeInstance

use of org.jbpm.workflow.instance.node.WorkItemNodeInstance in project jbpm by kiegroup.

the class RuntimeDataServiceEJBIntegrationTest method testGetTaskEvents.

@Test
public void testGetTaskEvents() {
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance instance = processService.getProcessInstance(processInstanceId);
    assertNotNull(instance);
    Collection<NodeInstance> activeNodes = ((WorkflowProcessInstanceImpl) instance).getNodeInstances();
    assertNotNull(activeNodes);
    assertEquals(1, activeNodes.size());
    NodeInstance node = activeNodes.iterator().next();
    assertNotNull(node);
    assertTrue(node instanceof WorkItemNodeInstance);
    Long workItemId = ((WorkItemNodeInstance) node).getWorkItemId();
    assertNotNull(workItemId);
    UserTaskInstanceDesc userTask = runtimeDataService.getTaskByWorkItemId(workItemId);
    assertNotNull(userTask);
    List<TaskEvent> auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
    assertNotNull(auditTasks);
    assertEquals(1, auditTasks.size());
    assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
    userTaskService.start(userTask.getTaskId(), "salaboy");
    auditTasks = runtimeDataService.getTaskEvents(userTask.getTaskId(), new QueryFilter());
    assertNotNull(auditTasks);
    assertEquals(2, auditTasks.size());
    assertEquals(TaskEvent.TaskEventType.ADDED, auditTasks.get(0).getType());
    assertEquals(TaskEvent.TaskEventType.STARTED, auditTasks.get(1).getType());
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) WorkflowProcessInstanceImpl(org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl) TaskEvent(org.kie.internal.task.api.model.TaskEvent) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) NodeInstance(org.kie.api.runtime.process.NodeInstance) WorkItemNodeInstance(org.jbpm.workflow.instance.node.WorkItemNodeInstance) Test(org.junit.Test)

Aggregations

WorkItemNodeInstance (org.jbpm.workflow.instance.node.WorkItemNodeInstance)18 NodeInstance (org.kie.api.runtime.process.NodeInstance)13 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)12 Test (org.junit.Test)11 WorkflowProcessInstanceImpl (org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)5 SubProcessNodeInstance (org.jbpm.workflow.instance.node.SubProcessNodeInstance)5 QueryFilter (org.kie.internal.query.QueryFilter)5 HashMap (java.util.HashMap)4 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)4 NodeInstanceImpl (org.jbpm.workflow.instance.impl.NodeInstanceImpl)4 WorkflowProcessInstance (org.kie.api.runtime.process.WorkflowProcessInstance)4 ArrayList (java.util.ArrayList)3 NodeInstanceLog (org.jbpm.process.audit.NodeInstanceLog)3 DynamicNodeInstance (org.jbpm.workflow.instance.node.DynamicNodeInstance)3 KieSession (org.kie.api.runtime.KieSession)3 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)2 NodeInstanceContent (org.jbpm.marshalling.impl.JBPMMessages.ProcessInstance.NodeInstanceContent)2 TextMapEntry (org.jbpm.marshalling.impl.JBPMMessages.ProcessInstance.NodeInstanceContent.RuleSetNode.TextMapEntry)2 ProcessInstanceImpl (org.jbpm.process.instance.impl.ProcessInstanceImpl)2