Search in sources :

Example 11 with ProcessInstance

use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceIntegrationTest method testGetProcessInstancesByCorrelationKeySortedById.

@Test
public void testGetProcessInstancesByCorrelationKeySortedById() throws Exception {
    CorrelationKeyFactory correlationKeyFactory = KieInternalServices.Factory.get().newCorrelationKeyFactory();
    String firstBusinessKey = "my-simple-key-first";
    String secondBusinessKey = "my-simple-key-second";
    CorrelationKey firstKey = correlationKeyFactory.newCorrelationKey(firstBusinessKey);
    CorrelationKey secondKey = correlationKeyFactory.newCorrelationKey(secondBusinessKey);
    CorrelationKey partKey = correlationKeyFactory.newCorrelationKey("my-simple%");
    Long processInstanceEvalutionId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, firstKey);
    Long processInstanceSignalId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_SIGNAL_PROCESS, secondKey);
    try {
        List<ProcessInstance> returnedProcessInstances = queryClient.findProcessInstancesByCorrelationKey(partKey, 0, 100, SORT_BY_INSTANCE_PROCESS_ID, false);
        assertNotNull(returnedProcessInstances);
        assertProcessInstancesOrderById(returnedProcessInstances, false);
        ProcessInstance returnedSignalProcess = findProcessInstance(returnedProcessInstances, processInstanceSignalId);
        assertEquals(PROCESS_ID_SIGNAL_PROCESS, returnedSignalProcess.getProcessId());
        assertEquals(processInstanceSignalId, returnedSignalProcess.getId());
        assertEquals(secondBusinessKey, returnedSignalProcess.getCorrelationKey());
        ProcessInstance returnedEvaluation = findProcessInstance(returnedProcessInstances, processInstanceEvalutionId);
        assertEquals(PROCESS_ID_EVALUATION, returnedEvaluation.getProcessId());
        assertEquals(processInstanceEvalutionId, returnedEvaluation.getId());
        assertEquals(firstBusinessKey, returnedEvaluation.getCorrelationKey());
    } finally {
        processClient.abortProcessInstance(CONTAINER_ID, processInstanceEvalutionId);
        processClient.abortProcessInstance(CONTAINER_ID, processInstanceSignalId);
    }
}
Also used : CorrelationKey(org.kie.internal.process.CorrelationKey) CorrelationKeyFactory(org.kie.internal.process.CorrelationKeyFactory) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Test(org.junit.Test)

Example 12 with ProcessInstance

use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceIntegrationTest method testGetProcessInstancesByVariableNameAndValueSortedByName.

@Test
public void testGetProcessInstancesByVariableNameAndValueSortedByName() throws Exception {
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("personData", createPersonInstance(USER_JOHN));
    List<Long> processInstanceIds = createProcessInstances(parameters);
    for (Long processInstanceId : processInstanceIds) {
        processClient.setProcessVariable(CONTAINER_ID, processInstanceId, "stringData", "waiting for signal");
    }
    try {
        List status = Arrays.asList(org.kie.api.runtime.process.ProcessInstance.STATE_ACTIVE);
        List<ProcessInstance> instances = queryClient.findProcessInstancesByVariableAndValue("stringData", "waiting%", status, 0, 3, SORT_BY_PROCESS_ID, true);
        assertNotNull(instances);
        assertEquals(3, instances.size());
        for (ProcessInstance instance : instances) {
            assertTrue(processInstanceIds.contains(instance.getId()));
            assertEquals(PROCESS_ID_SIGNAL_PROCESS, instance.getProcessId());
        }
        instances = queryClient.findProcessInstancesByVariableAndValue("stringData", "waiting%", status, 1, 3, SORT_BY_PROCESS_ID, true);
        assertNotNull(instances);
        assertEquals(2, instances.size());
        for (ProcessInstance instance : instances) {
            assertTrue(processInstanceIds.contains(instance.getId()));
            assertEquals(PROCESS_ID_USERTASK, instance.getProcessId());
        }
        instances = queryClient.findProcessInstancesByVariableAndValue("stringData", "waiting%", status, 0, 10, SORT_BY_PROCESS_ID, false);
        assertNotNull(instances);
        assertEquals(5, instances.size());
        for (int i = 0; i < instances.size(); i++) {
            if (i < 2) {
                assertEquals(PROCESS_ID_USERTASK, instances.get(i).getProcessId());
            } else {
                assertEquals(PROCESS_ID_SIGNAL_PROCESS, instances.get(i).getProcessId());
            }
        }
    } finally {
        abortProcessInstances(processInstanceIds);
    }
}
Also used : HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Test(org.junit.Test)

Example 13 with ProcessInstance

use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.

the class SLAComplianceIntegrationTest method assertProcessInstance.

private void assertProcessInstance(Long pid, int processState, int slaStatus) {
    assertThat(pid).isNotNull();
    ProcessInstance pi = queryClient.findProcessInstanceById(pid);
    assertThat(pi.getState()).isEqualTo(processState);
    assertThat(pi.getSlaCompliance()).isEqualTo(slaStatus);
    if (slaStatus != SLA_NA) {
        assertThat(pi.getSlaDueDate()).isCloseTo(new Date(), 30000);
    }
}
Also used : ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Date(java.util.Date)

Example 14 with ProcessInstance

use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.

the class ProcessSearchServiceIntegrationTest method testFindProcessInstanceWithStartDateGreaterThanOrEqualsToFilter.

@Test
public void testFindProcessInstanceWithStartDateGreaterThanOrEqualsToFilter() throws Exception {
    Map<String, Object> parameters = new HashMap<>();
    Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_EVALUATION, parameters);
    Assertions.assertThat(processInstanceId).isNotNull();
    ProcessInstance pi = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
    testFindProcessInstanceWithQueryFilter(createQueryFilterGreaterThanOrEqualsTo(ProcessInstanceField.START_DATE, subtractOneMinuteFromDate(pi.getDate())), processInstanceId);
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) Test(org.junit.Test)

Example 15 with ProcessInstance

use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.

the class ProcessSearchServiceIntegrationTest method testFindProcessInstanceWithQueryFilter.

private void testFindProcessInstanceWithQueryFilter(ProcessInstanceQueryFilterSpec filter, Long processInstanceId) {
    List<Long> resultsIds = new ArrayList<>();
    List<ProcessInstance> results;
    results = queryClient.findProcessInstancesWithFilters(QUERY_NAME, filter, 0, 100);
    for (ProcessInstance res : results) {
        resultsIds.add(res.getId());
    }
    Assertions.assertThat(results).isNotNull();
    Assertions.assertThat(results).isNotEmpty();
    Assertions.assertThat(resultsIds).contains(processInstanceId);
}
Also used : ArrayList(java.util.ArrayList) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance)

Aggregations

ProcessInstance (org.kie.server.api.model.instance.ProcessInstance)125 Test (org.junit.Test)97 HashMap (java.util.HashMap)75 TaskSummary (org.kie.server.api.model.instance.TaskSummary)31 ArrayList (java.util.ArrayList)24 QueryDefinition (org.kie.server.api.model.definition.QueryDefinition)22 KieServicesException (org.kie.server.api.exception.KieServicesException)17 ProcessDefinition (org.kie.server.api.model.definition.ProcessDefinition)11 List (java.util.List)9 QueryServicesClient (org.kie.server.client.QueryServicesClient)9 JbpmKieServerBaseIntegrationTest (org.kie.server.integrationtests.jbpm.JbpmKieServerBaseIntegrationTest)9 Category (org.junit.experimental.categories.Category)7 CorrelationKey (org.kie.internal.process.CorrelationKey)7 CorrelationKeyFactory (org.kie.internal.process.CorrelationKeyFactory)7 ProcessServicesClient (org.kie.server.client.ProcessServicesClient)7 Arrays (java.util.Arrays)6 Map (java.util.Map)6 Assertions (org.assertj.core.api.Assertions)6 After (org.junit.After)6 TaskInstance (org.kie.server.api.model.instance.TaskInstance)6