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