Search in sources :

Example 96 with ProcessInstanceQuery

use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class StartTimerEventTest method FAILING_testCycleDateStartTimerEvent.

// FIXME: This test likes to run in an endless loop when invoking the
// waitForJobExecutorOnCondition method
@Deployment
public void FAILING_testCycleDateStartTimerEvent() throws Exception {
    ClockUtil.setCurrentTime(new Date());
    // After process start, there should be timer created
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    final ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
    assertEquals(0, piq.count());
    moveByMinutes(5);
    executeAllJobs();
    assertEquals(1, piq.count());
    assertEquals(1, jobQuery.count());
    moveByMinutes(5);
    executeAllJobs();
    assertEquals(1, piq.count());
    assertEquals(1, jobQuery.count());
// have to manually delete pending timer
// cleanDB();
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Date(java.util.Date) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 97 with ProcessInstanceQuery

use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class StartTimerEventTest method testStartTimerEventSubProcessInMultiInstanceSubProcessWithNonInterruptingBoundaryTimerEvent.

/**
 * test scenario: - start process instance with multiInstance sequential -
 * execute interrupting timer job of event subprocess - execute non
 * interrupting timer boundary event of subprocess
 */
@Deployment
public void testStartTimerEventSubProcessInMultiInstanceSubProcessWithNonInterruptingBoundaryTimerEvent() {
    DummyServiceTask.wasExecuted = false;
    // start process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
    // check if user task exists
    TaskQuery taskQuery = taskService.createTaskQuery();
    assertEquals(1, taskQuery.count());
    JobQuery jobQuery = managementService.createJobQuery();
    // 1 start timer job and 1 boundary timer job
    assertEquals(2, jobQuery.count());
    // execute interrupting start timer event subprocess job
    managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(1).getId());
    assertEquals(true, DummyServiceTask.wasExecuted);
    // after first interrupting start timer event sub process execution
    // multiInstance loop number 2
    assertEquals(1, taskQuery.count());
    assertEquals(2, jobQuery.count());
    // execute non interrupting boundary timer job
    managementService.executeJob(jobQuery.orderByJobDuedate().asc().list().get(0).getId());
    // after non interrupting boundary timer job execution
    assertEquals(1, jobQuery.count());
    assertEquals(1, taskQuery.count());
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
    assertEquals(1, processInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 98 with ProcessInstanceQuery

use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class StartTimerEventTest method testStartTimerEventInEventSubProcess.

@Deployment
public void testStartTimerEventInEventSubProcess() {
    DummyServiceTask.wasExecuted = false;
    // start process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventInEventSubProcess");
    // check if execution exists
    ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
    assertEquals(1, executionQuery.count());
    // check if user task exists
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
    assertEquals(1, taskQuery.count());
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    // execute existing timer job
    managementService.executeJob(managementService.createJobQuery().list().get(0).getId());
    assertEquals(0, jobQuery.count());
    assertEquals(true, DummyServiceTask.wasExecuted);
    // check if user task doesn't exist because timer start event is
    // interrupting
    assertEquals(0, taskQuery.count());
    // check if execution doesn't exist because timer start event is
    // interrupting
    assertEquals(0, executionQuery.count());
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
    assertEquals(0, processInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 99 with ProcessInstanceQuery

use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class StartTimerEventTest method testStartTimerEventWithTwoEventSubProcesses.

@Deployment
public void testStartTimerEventWithTwoEventSubProcesses() {
    // start process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventWithTwoEventSubProcesses");
    // check if execution exists
    ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
    assertEquals(1, executionQuery.count());
    // check if user task exists
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
    assertEquals(1, taskQuery.count());
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(2, jobQuery.count());
    // get all timer jobs ordered by dueDate
    List<Job> orderedJobList = jobQuery.orderByJobDuedate().asc().list();
    // execute first timer job
    managementService.executeJob(orderedJobList.get(0).getId());
    assertEquals(0, jobQuery.count());
    // check if user task doesn't exist because timer start event is
    // interrupting
    assertEquals(0, taskQuery.count());
    // check if execution doesn't exist because timer start event is
    // interrupting
    assertEquals(0, executionQuery.count());
    // check if process instance doesn't exist because timer start event is
    // interrupting
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
    assertEquals(0, processInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) Job(org.camunda.bpm.engine.runtime.Job) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 100 with ProcessInstanceQuery

use of org.camunda.bpm.engine.runtime.ProcessInstanceQuery in project camunda-bpm-platform by camunda.

the class StartTimerEventTest method testNonInterruptingStartTimerEventSubProcessInSubProcess.

@Deployment
public void testNonInterruptingStartTimerEventSubProcessInSubProcess() {
    DummyServiceTask.wasExecuted = false;
    // start process instance
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingStartTimerEventSubProcessInSubProcess");
    // check if execution exists
    ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId());
    assertEquals(2, executionQuery.count());
    // check if user task exists
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(processInstance.getId());
    assertEquals(1, taskQuery.count());
    JobQuery jobQuery = managementService.createJobQuery();
    assertEquals(1, jobQuery.count());
    // execute existing timer job
    managementService.executeJob(jobQuery.list().get(0).getId());
    assertEquals(0, jobQuery.count());
    assertEquals(true, DummyServiceTask.wasExecuted);
    // check if user task still exists because timer start event is non
    // interrupting
    assertEquals(1, taskQuery.count());
    // check if execution still exists because timer start event is non
    // interrupting
    assertEquals(2, executionQuery.count());
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
    assertEquals(1, processInstanceQuery.count());
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) TaskQuery(org.camunda.bpm.engine.task.TaskQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) JobQuery(org.camunda.bpm.engine.runtime.JobQuery) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)201 Test (org.junit.Test)127 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)59 Deployment (org.camunda.bpm.engine.test.Deployment)42 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)34 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)27 HashMap (java.util.HashMap)24 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)19 Batch (org.camunda.bpm.engine.batch.Batch)18 JobQuery (org.camunda.bpm.engine.runtime.JobQuery)17 ArrayList (java.util.ArrayList)16 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)15 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)15 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)14 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)12 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)9 Job (org.camunda.bpm.engine.runtime.Job)9 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)8 AbstractAsyncOperationsTest (org.camunda.bpm.engine.test.api.AbstractAsyncOperationsTest)8 Response (com.jayway.restassured.response.Response)7