use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByActivityIdBeforeCompensation.
@Test
public void testQueryByActivityIdBeforeCompensation() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
// when
runtimeService.startProcessInstanceById(testProcess.getId());
testHelper.completeTask("userTask1");
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertNoProcessInstancesReturned(query);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByActivityIdDuringCompensation.
@Test
public void testQueryByActivityIdDuringCompensation() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
// when
ProcessInstance processInstance = runtimeService.startProcessInstanceById(testProcess.getId());
testHelper.completeTask("userTask1");
testHelper.completeTask("userTask2");
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertReturnedProcessInstances(query, processInstance);
query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationEvent");
assertReturnedProcessInstances(query, processInstance);
query = runtimeService.createProcessInstanceQuery().activityIdIn("compensationHandler");
assertReturnedProcessInstances(query, processInstance);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByAsyncAfterActivityId.
@Test
public void testQueryByAsyncAfterActivityId() {
// given
ProcessDefinition testProcess = testHelper.deployAndGetDefinition(ProcessModels.newModel().startEvent("start").camundaAsyncAfter().subProcess("subProcess").camundaAsyncAfter().embeddedSubProcess().startEvent().serviceTask("task").camundaAsyncAfter().camundaExpression("${true}").endEvent().subProcessDone().endEvent("end").camundaAsyncAfter().done());
// when
ProcessInstance instanceAfterStart = runtimeService.startProcessInstanceById(testProcess.getId());
ProcessInstance instanceAfterTask = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterTask);
ProcessInstance instanceAfterSubProcess = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterSubProcess);
executeJobForProcessInstance(instanceAfterSubProcess);
ProcessInstance instanceAfterEnd = runtimeService.startProcessInstanceById(testProcess.getId());
executeJobForProcessInstance(instanceAfterEnd);
executeJobForProcessInstance(instanceAfterEnd);
executeJobForProcessInstance(instanceAfterEnd);
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("start");
assertReturnedProcessInstances(query, instanceAfterStart);
query = runtimeService.createProcessInstanceQuery().activityIdIn("task");
assertReturnedProcessInstances(query, instanceAfterTask);
query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess");
assertReturnedProcessInstances(query, instanceAfterSubProcess);
query = runtimeService.createProcessInstanceQuery().activityIdIn("end");
assertReturnedProcessInstances(query, instanceAfterEnd);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceQueryTest method testQueryByNonLeafActivityId.
@Test
public void testQueryByNonLeafActivityId() {
// given
ProcessDefinition processDefinition = testHelper.deployAndGetDefinition(FORK_JOIN_SUB_PROCESS_MODEL);
// when
runtimeService.startProcessInstanceById(processDefinition.getId());
// then
ProcessInstanceQuery query = runtimeService.createProcessInstanceQuery().activityIdIn("subProcess", "fork");
assertNoProcessInstancesReturned(query);
}
use of org.camunda.bpm.engine.repository.ProcessDefinition in project camunda-bpm-platform by camunda.
the class ProcessInstanceSuspensionTest method testSignalEventReceivedAfterProcessInstanceSuspendedByProcessDefinitionKey.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/ProcessInstanceSuspensionTest.testSignalEventReceivedAfterProcessInstanceSuspended.bpmn20.xml" })
public void testSignalEventReceivedAfterProcessInstanceSuspendedByProcessDefinitionKey() {
final String signal = "Some Signal";
// Test if process instance can be completed using the signal
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
runtimeService.signalEventReceived(signal);
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
// Now test when suspending the process instance: the process instance shouldn't be continued
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("signalSuspendedProcessInstance").singleResult();
processInstance = runtimeService.startProcessInstanceByKey("signalSuspendedProcessInstance");
runtimeService.suspendProcessInstanceByProcessDefinitionKey(processDefinition.getKey());
runtimeService.signalEventReceived(signal);
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
runtimeService.signalEventReceived(signal, new HashMap<String, Object>());
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult();
try {
runtimeService.signalEventReceived(signal, subscription.getExecutionId());
fail();
} catch (SuspendedEntityInteractionException e) {
// This is expected
assertTextPresent("is suspended", e.getMessage());
}
try {
runtimeService.signalEventReceived(signal, subscription.getExecutionId(), new HashMap<String, Object>());
fail();
} catch (SuspendedEntityInteractionException e) {
// This is expected
assertTextPresent("is suspended", e.getMessage());
}
// Activate and try again
runtimeService.activateProcessInstanceById(processInstance.getId());
runtimeService.signalEventReceived(signal);
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
Aggregations