Search in sources :

Example 86 with ProcessInstanceDesc

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());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 87 with ProcessInstanceDesc

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());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 88 with ProcessInstanceDesc

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

Example 89 with ProcessInstanceDesc

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());
}
Also used : ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) Test(org.junit.Test)

Example 90 with ProcessInstanceDesc

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;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) RemoteMap(org.jbpm.services.ejb.remote.api.RemoteMap) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)198 Test (org.junit.Test)147 QueryContext (org.kie.api.runtime.query.QueryContext)123 ArrayList (java.util.ArrayList)75 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)57 HashMap (java.util.HashMap)32 AbstractCaseServicesBaseTest (org.jbpm.casemgmt.impl.util.AbstractCaseServicesBaseTest)25 TaskSummary (org.kie.api.task.model.TaskSummary)25 QueryFilter (org.kie.internal.query.QueryFilter)23 RemoteEjbTest (org.jbpm.remote.ejb.test.RemoteEjbTest)17 CaseInstance (org.jbpm.casemgmt.api.model.instance.CaseInstance)16 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)16 UserTaskInstanceDesc (org.jbpm.services.api.model.UserTaskInstanceDesc)15 CaseNotFoundException (org.jbpm.casemgmt.api.CaseNotFoundException)12 CaseFileInstance (org.jbpm.casemgmt.api.model.instance.CaseFileInstance)12 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)11 CorrelationKey (org.kie.internal.process.CorrelationKey)11 SqlQueryDefinition (org.jbpm.kie.services.impl.query.SqlQueryDefinition)9 List (java.util.List)7