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);
}
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);
}
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());
}
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);
}
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());
}
Aggregations