Search in sources :

Example 31 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class RuntimeDataServiceImplTest method testGetProcessInstanceByCorrelationKey.

@Test
public void testGetProcessInstanceByCorrelationKey() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
    assertNotNull(processInstanceId);
    ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
    List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    UserTaskInstanceDesc activeTask = tasks.get(0);
    assertNotNull(activeTask);
    assertEquals(Status.Reserved.name(), activeTask.getStatus());
    assertEquals(instance.getId(), activeTask.getProcessInstanceId());
    assertEquals(instance.getProcessId(), activeTask.getProcessId());
    assertEquals("Write a Document", activeTask.getName());
    assertEquals("salaboy", activeTask.getActualOwner());
    assertEquals(deploymentUnit.getIdentifier(), activeTask.getDeploymentId());
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    processInstanceId = null;
    assertNull(instance);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 32 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstanceByCorrelationKey.

@Test
public void testGetProcessInstanceByCorrelationKey() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
    assertNotNull(processInstanceId);
    ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
    List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    UserTaskInstanceDesc activeTask = tasks.get(0);
    assertNotNull(activeTask);
    assertEquals(Status.Reserved.name(), activeTask.getStatus());
    assertEquals(instance.getId(), activeTask.getProcessInstanceId());
    assertEquals(instance.getProcessId(), activeTask.getProcessId());
    assertEquals("Write a Document", activeTask.getName());
    assertEquals("salaboy", activeTask.getActualOwner());
    assertEquals(deploymentUnit.getIdentifier(), activeTask.getDeploymentId());
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    processInstanceId = null;
    assertNull(instance);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) Test(org.junit.Test)

Example 33 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class RuntimeDataServiceEJBIntegrationTest method testGetProcessInstancesByCorrelationKey.

@Test
public void testGetProcessInstancesByCorrelationKey() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
    assertNotNull(processInstanceId);
    Collection<ProcessInstanceDesc> keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(key, new QueryContext());
    assertNotNull(keyedInstances);
    assertEquals(1, keyedInstances.size());
    ProcessInstanceDesc instance = keyedInstances.iterator().next();
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
    List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
    assertNull(tasks);
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    processInstanceId = null;
    assertNull(instance);
    keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(key, new QueryContext());
    assertNotNull(keyedInstances);
    assertEquals(1, keyedInstances.size());
    instance = keyedInstances.iterator().next();
    assertEquals(3, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) Test(org.junit.Test)

Example 34 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstanceByCorrelationKey.

@Test
public void testGetProcessInstanceByCorrelationKey() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
    assertNotNull(processInstanceId);
    ProcessInstanceDesc instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
    List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
    assertNotNull(tasks);
    assertEquals(1, tasks.size());
    UserTaskInstanceDesc activeTask = tasks.get(0);
    assertNotNull(activeTask);
    assertEquals(Status.Reserved.name(), activeTask.getStatus());
    assertEquals(instance.getId(), activeTask.getProcessInstanceId());
    assertEquals(instance.getProcessId(), activeTask.getProcessId());
    assertEquals("Write a Document", activeTask.getName());
    assertEquals("salaboy", activeTask.getActualOwner());
    assertEquals(deploymentUnit.getIdentifier(), activeTask.getDeploymentId());
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    processInstanceId = null;
    assertNull(instance);
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) Test(org.junit.Test)

Example 35 with CorrelationKey

use of org.kie.internal.process.CorrelationKey in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByCorrelationKey.

@Test
public void testGetProcessInstancesByCorrelationKey() {
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    identityProvider.setRoles(roles);
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey("my business key");
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", key);
    assertNotNull(processInstanceId);
    Collection<ProcessInstanceDesc> keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(key, new QueryContext());
    assertNotNull(keyedInstances);
    assertEquals(1, keyedInstances.size());
    ProcessInstanceDesc instance = keyedInstances.iterator().next();
    assertNotNull(instance);
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
    List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
    assertNull(tasks);
    processService.abortProcessInstance(processInstanceId);
    instance = runtimeDataService.getProcessInstanceByCorrelationKey(key);
    processInstanceId = null;
    assertNull(instance);
    keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(key, new QueryContext());
    assertNotNull(keyedInstances);
    assertEquals(1, keyedInstances.size());
    instance = keyedInstances.iterator().next();
    assertEquals(3, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    assertEquals("my business key", instance.getCorrelationKey());
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc) Test(org.junit.Test)

Aggregations

CorrelationKey (org.kie.internal.process.CorrelationKey)38 Test (org.junit.Test)27 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)12 QueryContext (org.kie.api.runtime.query.QueryContext)12 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)8 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)7 CorrelationKeyFactory (org.kie.internal.process.CorrelationKeyFactory)7 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)6 KieSession (org.kie.api.runtime.KieSession)6 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)5 Collection (java.util.Collection)4 List (java.util.List)4 Map (java.util.Map)4 Collectors.toList (java.util.stream.Collectors.toList)4 RegistryContext (org.drools.core.command.impl.RegistryContext)4 CaseEventSupport (org.jbpm.casemgmt.impl.event.CaseEventSupport)4 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)4