use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableValueEquals_Integer.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueEquals_Integer() {
// given
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("intValue", 1234);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueEquals("intValue", 1234);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(1, query.count());
VariableInstance var = result.get(0);
assertEquals("intValue", var.getName());
assertEquals(1234, var.getValue());
assertEquals("integer", var.getTypeName());
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryOrderByName_Asc.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryOrderByName_Asc() {
// given
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "test");
variables.put("myVar", "test123");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().orderByVariableName().asc();
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
VariableInstance first = result.get(0);
VariableInstance second = result.get(1);
assertEquals("myVar", first.getName());
assertEquals("stringVar", second.getName());
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testSubProcessVariablesWithParallelGateway.
@Test
@Deployment
public void testSubProcessVariablesWithParallelGateway() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertNotNull(tree);
ActivityInstance[] subprocessInstances = tree.getActivityInstances("SubProcess_1");
assertEquals(5, subprocessInstances.length);
// when
String activityInstanceId1 = subprocessInstances[0].getId();
VariableInstanceQuery query1 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId1);
String activityInstanceId2 = subprocessInstances[1].getId();
VariableInstanceQuery query2 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId2);
String activityInstanceId3 = subprocessInstances[2].getId();
VariableInstanceQuery query3 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId3);
String activityInstanceId4 = subprocessInstances[3].getId();
VariableInstanceQuery query4 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId4);
String activityInstanceId5 = subprocessInstances[4].getId();
VariableInstanceQuery query5 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(activityInstanceId5);
// then
checkVariables(query1.list());
checkVariables(query2.list());
checkVariables(query3.list());
checkVariables(query4.list());
checkVariables(query5.list());
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableValueLikeWithEscape_String.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueLikeWithEscape_String() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("stringVar", "test_123");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("stringVar", "test%456");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueLike("stringVar", "test\\_%");
verifyQueryResult(query, "test_123");
query = runtimeService.createVariableInstanceQuery().variableValueLike("stringVar", "test\\%%");
verifyQueryResult(query, "test%456");
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableValueNotEquals_Integer.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueNotEquals_Integer() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("intValue", 1234);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("intValue", 5555);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueNotEquals("intValue", 5555);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(1, query.count());
VariableInstance var = result.get(0);
assertEquals("intValue", var.getName());
assertEquals(1234, var.getValue());
assertEquals("integer", var.getTypeName());
}
Aggregations