use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testQueryBySignalSubscriptionName.
@Deployment
public void testQueryBySignalSubscriptionName() {
runtimeService.startProcessInstanceByKey("catchSignal");
// it finds subscribed instances
Execution execution = runtimeService.createExecutionQuery().signalEventSubscription("alert").singleResult();
assertNotNull(execution);
// test query for nonexisting subscription
execution = runtimeService.createExecutionQuery().signalEventSubscription("nonExisitng").singleResult();
assertNull(execution);
// it finds more than one
runtimeService.startProcessInstanceByKey("catchSignal");
assertEquals(2, runtimeService.createExecutionQuery().signalEventSubscription("alert").count());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testQueryByIncidentMessage.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentMessage() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
executeAvailableJobs();
List<Incident> incidentList = runtimeService.createIncidentQuery().list();
assertEquals(1, incidentList.size());
Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
List<Execution> executionList = runtimeService.createExecutionQuery().incidentMessage(incident.getIncidentMessage()).list();
assertEquals(1, executionList.size());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testExecutionQueryWithProcessVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testExecutionQueryWithProcessVariable() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("x", "parent");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("concurrent", variables);
List<Execution> concurrentExecutions = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).list();
assertEquals(3, concurrentExecutions.size());
for (Execution execution : concurrentExecutions) {
if (!((ExecutionEntity) execution).isProcessInstanceExecution()) {
// only the concurrent executions, not the root one, would be cooler to query that directly, see http://jira.codehaus.org/browse/ACT-1373
runtimeService.setVariableLocal(execution.getId(), "x", "child");
}
}
assertEquals(2, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "child").count());
assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "parent").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEquals("x", "parent").count());
assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueNotEquals("x", "xxx").count());
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testExecutionQueryForSuspendedExecutions.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testExecutionQueryForSuspendedExecutions() {
List<Execution> suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
assertEquals(suspendedExecutions.size(), 0);
for (String instanceId : concurrentProcessInstanceIds) {
runtimeService.suspendProcessInstanceById(instanceId);
}
suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
assertEquals(12, suspendedExecutions.size());
List<Execution> activeExecutions = runtimeService.createExecutionQuery().active().list();
assertEquals(1, activeExecutions.size());
for (Execution activeExecution : activeExecutions) {
assertEquals(activeExecution.getProcessInstanceId(), sequentialProcessInstanceIds.get(0));
}
}
use of org.camunda.bpm.engine.runtime.Execution in project camunda-bpm-platform by camunda.
the class ExecutionQueryTest method testQueryNullVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryNullVariable() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
vars.put("nullVar", null);
ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("nullVar", "notnull");
ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("nullVarLong", "notnull");
ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("nullVarDouble", "notnull");
ProcessInstance processInstance4 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
vars = new HashMap<String, Object>();
vars.put("nullVarByte", "testbytes".getBytes());
ProcessInstance processInstance5 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
// Query on null value, should return one value
ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("nullVar", null);
List<Execution> executions = query.list();
Assert.assertNotNull(executions);
Assert.assertEquals(1, executions.size());
Assert.assertEquals(processInstance1.getId(), executions.get(0).getId());
// Test NOT_EQUALS null
Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVar", null).count());
Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarLong", null).count());
Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarDouble", null).count());
// When a byte-array refrence is present, the variable is not considered null
Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarByte", null).count());
// All other variable queries with null should throw exception
try {
runtimeService.createExecutionQuery().variableValueGreaterThan("nullVar", null);
fail("Excetion expected");
} catch (ProcessEngineException ae) {
assertTextPresent("Booleans and null cannot be used in 'greater than' condition", ae.getMessage());
}
try {
runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("nullVar", null);
fail("Excetion expected");
} catch (ProcessEngineException ae) {
assertTextPresent("Booleans and null cannot be used in 'greater than or equal' condition", ae.getMessage());
}
try {
runtimeService.createExecutionQuery().variableValueLessThan("nullVar", null);
fail("Excetion expected");
} catch (ProcessEngineException ae) {
assertTextPresent("Booleans and null cannot be used in 'less than' condition", ae.getMessage());
}
try {
runtimeService.createExecutionQuery().variableValueLessThanOrEqual("nullVar", null);
fail("Excetion expected");
} catch (ProcessEngineException ae) {
assertTextPresent("Booleans and null cannot be used in 'less than or equal' condition", ae.getMessage());
}
try {
runtimeService.createExecutionQuery().variableValueLike("nullVar", null);
fail("Excetion expected");
} catch (ProcessEngineException ae) {
assertTextPresent("Booleans and null cannot be used in 'like' condition", ae.getMessage());
}
runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
runtimeService.deleteProcessInstance(processInstance4.getId(), "test");
runtimeService.deleteProcessInstance(processInstance5.getId(), "test");
}
Aggregations