Search in sources :

Example 61 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() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    roles.add("employees");
    identityProvider.setRoles(roles);
    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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 62 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByProcessIdAndStateNoAccess.

@Test
public void testGetProcessInstancesByProcessIdAndStateNoAccess() {
    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.writedocument", null, new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstancesByProcessId(states, "org.jbpm.writedocument", null, 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 63 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByProcessId.

@Test
public void testGetProcessInstancesByProcessId() {
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    roles.add("employees");
    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(1, instances.size());
    ProcessInstanceDesc instance = instances.iterator().next();
    assertEquals(1, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
    List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter(0, 10));
    assertNotNull(taskSummaries);
    assertEquals(1, taskSummaries.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstancesByProcessDefinition("org.jbpm.writedocument", new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    instance = instances.iterator().next();
    assertEquals(3, (int) instance.getState());
    assertEquals("org.jbpm.writedocument", instance.getProcessId());
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 64 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByStateAndInitiatorNoAccess.

@Test
public void testGetProcessInstancesByStateAndInitiatorNoAccess() {
    Collection<ProcessInstanceDesc> instances = runtimeDataService.getProcessInstances(new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    roles.add("employees");
    identityProvider.setRoles(roles);
    processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    List<Integer> states = new ArrayList<Integer>();
    // search for active only
    states.add(1);
    instances = runtimeDataService.getProcessInstances(states, correctUser, new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    instances = runtimeDataService.getProcessInstances(states, wrongUser, new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstances(states, correctUser, 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) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 65 with ProcessInstanceDesc

use of org.jbpm.services.api.model.ProcessInstanceDesc in project jbpm by kiegroup.

the class RuntimeDataServiceImplSecurityTest method testGetProcessInstancesByStateAndInitiator.

@Test
public void testGetProcessInstancesByStateAndInitiator() {
    // let's grant managers role so process can be started
    List<String> roles = new ArrayList<String>();
    roles.add("managers");
    roles.add("employees");
    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 active only
    states.add(1);
    instances = runtimeDataService.getProcessInstances(states, correctUser, new QueryContext());
    assertNotNull(instances);
    assertEquals(1, instances.size());
    assertEquals(1, (int) instances.iterator().next().getState());
    instances = runtimeDataService.getProcessInstances(states, wrongUser, new QueryContext());
    assertNotNull(instances);
    assertEquals(0, instances.size());
    processService.abortProcessInstance(processInstanceId);
    processInstanceId = null;
    instances = runtimeDataService.getProcessInstances(states, correctUser, 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) 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