use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class TimerRollbackRegressionIntegrationTest method disposeContainers.
@After
public void disposeContainers() {
String containerId = "timer-rollback-project-" + runtimeStrategy;
List<ProcessInstance> startedInstances = queryClient.findProcessInstancesByContainerId(containerId, null, 0, 10, "log.processInstanceId", false);
for (ProcessInstance processInstanceId : startedInstances) {
processClient.abortProcessInstance(containerId, processInstanceId.getId());
}
disposeAllContainers();
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskEscalationIntegrationTest method testRepeatedEscalationsWhenNotCompleted.
@Test(timeout = 15000)
// Potentially unstable on slow DBs.
@Category(Unstable.class)
public void testRepeatedEscalationsWhenNotCompleted() throws Exception {
Long processInstanceId;
processInstanceId = processClient.startProcess(CONTAINER_ID_NOTIFICATION, "repeatedEmailNotificationProcess");
assertNotNull(processInstanceId);
assertTrue(processInstanceId > 0);
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
Assertions.assertThat(tasks).hasSize(1);
taskClient.startTask(CONTAINER_ID_NOTIFICATION, tasks.get(0).getId(), USER_YODA);
Thread.sleep(6000L);
// 1 NotCompleted repeated notification
assertTotalOfEmails(1);
assertEmails("NotCompleted repeated notification every 5secs", "NotCompleted repeated notification every 5secs", USER_YODA, 1);
taskClient.completeTask(CONTAINER_ID_NOTIFICATION, tasks.get(0).getId(), USER_YODA, new HashMap<>());
Thread.sleep(6000L);
// No new notifications should be received
assertTotalOfEmails(1);
assertEmails("NotCompleted repeated notification every 5secs", "NotCompleted repeated notification every 5secs", USER_YODA, 1);
ProcessInstance processInstance = processClient.getProcessInstance(CONTAINER_ID_NOTIFICATION, processInstanceId);
assertNotNull(processInstance);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, processInstance.getState().intValue());
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class QueryClientIntegrationTest method testFindProcessInstances.
@Test
public void testFindProcessInstances() {
final Long processInstanceId = startProcess(CONTAINER_ID, PROCESS_WITH_SIGNAL_ID);
final Map<String, Object> parameters = new HashMap<>();
parameters.put("page", "0");
parameters.put("pageSize", "10");
final ExecutionServerCommand executionServerCommand = new ExecutionServerCommand();
executionServerCommand.setClient("query");
executionServerCommand.setOperation("findProcessInstances");
executionServerCommand.setParameters(parameters);
final Object response = runOnExecutionServer(executionServerCommand);
Assertions.assertThat(response).isNotNull();
Assertions.assertThat(response).isInstanceOf(List.class);
final List<ProcessInstance> processInstances = (List<ProcessInstance>) response;
Assertions.assertThat(processInstances).isNotEmpty();
final List<Long> processInstancesIds = processInstances.stream().map(p -> p.getId()).collect(Collectors.toList());
Assertions.assertThat(processInstancesIds).contains(processInstanceId);
sendSignalToProcessInstance(CONTAINER_ID, processInstanceId, SIGNAL_NAME);
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceAdminServiceIntegrationTest method testUpdateTimer.
@Test(timeout = 60 * 1000)
public void testUpdateTimer() throws Exception {
Map<String, Object> parameters = new HashMap<>();
parameters.put("timer", "1h");
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_TIMER, parameters);
assertNotNull(processInstanceId);
assertTrue(processInstanceId.longValue() > 0);
try {
List<TimerInstance> timers = processAdminClient.getTimerInstances(CONTAINER_ID, processInstanceId);
assertNotNull(timers);
assertEquals(1, timers.size());
TimerInstance timerInstance = timers.get(0);
assertNotNull(timerInstance);
assertEquals("timer", timerInstance.getTimerName());
assertNotNull(timerInstance.getId());
assertNotNull(timerInstance.getTimerId());
processAdminClient.updateTimer(CONTAINER_ID, processInstanceId, timerInstance.getId(), 3, 0, 0);
KieServerSynchronization.waitForProcessInstanceToFinish(processClient, CONTAINER_ID, processInstanceId);
ProcessInstance pi = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(pi);
assertEquals(org.kie.api.runtime.process.ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
} catch (Exception e) {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
fail(e.getMessage());
}
}
use of org.kie.server.api.model.instance.ProcessInstance in project droolsjbpm-integration by kiegroup.
the class ProcessInstanceMigrationIntegrationTest method testUpgradeParentInstanceWithMultipleSubprocesses.
@Test
public void testUpgradeParentInstanceWithMultipleSubprocesses() {
Long processParentInstanceId = processClient.startProcess(CONTAINER_ID, PARENT_WITH_MULTIPLE_SUBPROCESSES_ID);
assertNotNull(processParentInstanceId);
assertTrue(processParentInstanceId > 0);
logger.info("Process in container {} has started {}", CONTAINER_ID, processParentInstanceId);
List<ProcessInstance> childrenProcessInstance = processClient.findProcessInstancesByParent(CONTAINER_ID, processParentInstanceId, 0, 10);
assertEquals(1, childrenProcessInstance.size());
assertProcessInstancesInfo(childrenProcessInstance, "subprocessCallingAnotherSubProcess", "1.0", CONTAINER_ID, SUBPROCESS_CALLING_ANOTHER_SUBPROCESS_ID, processParentInstanceId);
List<ProcessInstance> childrenSubProcessInstance = processClient.findProcessInstancesByParent(CONTAINER_ID, childrenProcessInstance.get(0).getId(), 0, 10);
assertEquals(1, childrenSubProcessInstance.size());
assertProcessInstancesInfo(childrenSubProcessInstance, "subprocess", "1.0", CONTAINER_ID, SUBPROCESS_ID, childrenSubProcessInstance.get(0).getParentId());
List<TaskSummary> tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertEquals(1, tasks.size());
assertTasksInfo(tasks, "Evaluate items?", CONTAINER_ID, SUBPROCESS_ID);
MigrationSpecification spec = new MigrationSpecification();
MigrationProcessSpecification pSpecParent = new MigrationProcessSpecification();
pSpecParent.setSourceProcessId(PARENT_WITH_MULTIPLE_SUBPROCESSES_ID);
pSpecParent.setTargetProcessId(PARENT_WITH_MULTIPLE_SUBPROCESSES_ID_2);
MigrationProcessSpecification pSpecChild = new MigrationProcessSpecification();
pSpecChild.setSourceProcessId(SUBPROCESS_CALLING_ANOTHER_SUBPROCESS_ID);
pSpecChild.setTargetProcessId(SUBPROCESS_CALLING_ANOTHER_SUBPROCESS_ID_2);
MigrationProcessSpecification pSpecSubChild = new MigrationProcessSpecification();
pSpecSubChild.setSourceProcessId(SUBPROCESS_ID);
pSpecSubChild.setTargetProcessId(SUBPROCESS_ID_2);
spec.setProcesses(Arrays.asList(pSpecParent, pSpecChild, pSpecSubChild));
ProcessInstance piMigrate = processClient.getProcessInstance(CONTAINER_ID, processParentInstanceId);
assertProcessInstanceInfo(piMigrate, "parentWithMultipleSubProcesses", "1.0", CONTAINER_ID, PARENT_WITH_MULTIPLE_SUBPROCESSES_ID);
logger.info("about to process migration from container {} to {} with process definition {} with id {}", piMigrate.getContainerId(), CONTAINER_ID_2, piMigrate.getProcessId(), processParentInstanceId);
assertMigrateProcessInstanceWithSubprocess(processParentInstanceId, CONTAINER_ID, CONTAINER_ID_2, spec, 3);
piMigrate = processClient.getProcessInstance(CONTAINER_ID_2, processParentInstanceId);
assertNotNull(piMigrate);
assertProcessInstanceInfo(piMigrate, "parentWithMultipleSubProcesses2", "1.0.1", CONTAINER_ID_2, PARENT_WITH_MULTIPLE_SUBPROCESSES_ID_2);
childrenProcessInstance = processClient.findProcessInstancesByParent(CONTAINER_ID_2, processParentInstanceId, 0, 10);
logger.info("children instance from {} fetched", CONTAINER_ID_2);
assertEquals(1, childrenProcessInstance.size());
assertProcessInstancesInfo(childrenProcessInstance, "subprocessCallingAnotherSubProcess2", "1.0.1", CONTAINER_ID_2, SUBPROCESS_CALLING_ANOTHER_SUBPROCESS_ID_2, processParentInstanceId);
childrenSubProcessInstance = processClient.findProcessInstancesByParent(CONTAINER_ID_2, childrenProcessInstance.get(0).getId(), 0, 10);
logger.info("children instance from {} fetched", CONTAINER_ID_2);
assertEquals(1, childrenSubProcessInstance.size());
assertProcessInstancesInfo(childrenSubProcessInstance, "subprocess2", "1.0.1", CONTAINER_ID_2, SUBPROCESS_ID_2, childrenProcessInstance.get(0).getId());
// it stays in the same task
tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10);
assertAndCompleteTasks(tasks, 1, USER_YODA, CONTAINER_ID_2, SUBPROCESS_ID_2);
logger.info("migration tested!");
}
Aggregations