use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesNoAccess.
/*
* same tests but for user who does not have access rights to that
*/
@Test
public void testGetProcessInstancesNoAccess() {
List<String> roles = new ArrayList<String>();
identityProvider.setRoles(roles);
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByProcessIdNoAccess.
@Test
public void testGetProcessInstancesByProcessIdNoAccess() {
List<String> roles = new ArrayList<String>();
identityProvider.setRoles(roles);
Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
instances = runtimeDataService.getProcessInstancesByProcessDefinition("org.jbpm.writedocument", new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstancesByProcessDefinition("org.jbpm.writedocument", new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
}
use of org.jbpm.services.api.model.ProcessInstanceDesc 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.ProcessInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByPartialProcessIdAndState.
@Test
public void testGetProcessInstancesByPartialProcessIdAndState() {
// 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());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
List<Integer> states = new ArrayList<Integer>();
// search for aborted only
states.add(3);
instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm%", null, new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm%", null, new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(3, (int) instances.iterator().next().getState());
}
use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.
the class ClientProcessServiceWithCustomDataEJBTest method testStartProcessWithCustomData.
@Test
public void testStartProcessWithCustomData() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
Map<String, Object> parameters = new RemoteMap();
Object person = getInstance("org.jbpm.test.Person", new Object[] { "john", 25, true });
parameters.put("person", person);
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "custom-data-project.work-on-custom-data", parameters);
assertNotNull(processInstanceId);
List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter(0, 10));
assertNotNull(taskSummaries);
assertEquals(1, taskSummaries.size());
List<Long> tasks = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(tasks);
assertEquals(1, tasks.size());
Long taskId = tasks.get(0);
userTaskService.start(taskId, "john");
Map<String, Object> data = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(data);
Object fromTaskPerson = data.get("_person");
assertNotNull(fromTaskPerson);
assertEquals("john", getFieldValue(fromTaskPerson, "name"));
setFieldValue(fromTaskPerson, "name", "John Doe");
RemoteMap outcome = new RemoteMap();
outcome.put("person_", fromTaskPerson);
userTaskService.complete(taskId, "john", outcome);
ProcessInstanceDesc desc = runtimeDataService.getProcessInstanceById(processInstanceId);
assertNotNull(desc);
assertEquals(2, (int) desc.getState());
processInstanceId = null;
}
Aggregations