use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByPartialCorrelationKey.
@Test
public void testGetProcessInstancesByPartialCorrelationKey() {
// 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());
List<String> props = new ArrayList<String>();
props.add("first");
props.add("second");
props.add("third");
List<String> partial1props = new ArrayList<String>();
partial1props.add("first");
partial1props.add("second");
List<String> partial2props = new ArrayList<String>();
partial2props.add("first");
CorrelationKey key = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(props);
CorrelationKey partialKey1 = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(partial1props);
CorrelationKey partialKey2 = KieInternalServices.Factory.get().newCorrelationKeyFactory().newCorrelationKey(partial2props);
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("first:second:third", instance.getCorrelationKey());
List<UserTaskInstanceDesc> tasks = instance.getActiveTasks();
assertNull(tasks);
// search by partial key 1
keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(partialKey1, new QueryContext());
assertNotNull(keyedInstances);
assertEquals(1, keyedInstances.size());
instance = keyedInstances.iterator().next();
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("first:second:third", instance.getCorrelationKey());
// search by partial key 2
keyedInstances = runtimeDataService.getProcessInstancesByCorrelationKey(partialKey2, new QueryContext());
assertNotNull(keyedInstances);
assertEquals(1, keyedInstances.size());
instance = keyedInstances.iterator().next();
assertNotNull(instance);
assertEquals(1, (int) instance.getState());
assertEquals("org.jbpm.writedocument", instance.getProcessId());
assertEquals("first:second:third", instance.getCorrelationKey());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceEJBIntegrationTest method testStartAndForward.
@Test
public void testStartAndForward() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.start(taskId, "salaboy");
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.InProgress.toString(), task.getStatus());
userTaskService.forward(taskId, "salaboy", "john");
task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Ready.toString(), task.getStatus());
assertEquals("", task.getActualOwner());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceEJBIntegrationTest method testExit.
@Test
public void testExit() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.exit(taskId, "Administrator");
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Exited.toString(), task.getStatus());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceEJBIntegrationTest method testActivate.
@Test
public void testActivate() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument.empty");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.activate(taskId, "Administrator");
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Ready.toString(), task.getStatus());
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskServiceEJBIntegrationTest method testReleaseAndClaim.
@Test
public void testReleaseAndClaim() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
userTaskService.release(taskId, "salaboy");
UserTaskInstanceDesc task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Ready.toString(), task.getStatus());
userTaskService.claim(taskId, "salaboy");
task = runtimeDataService.getTaskById(taskId);
assertNotNull(task);
assertEquals(Status.Reserved.toString(), task.getStatus());
}
Aggregations