use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableGreaterThan_Long.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableGreaterThan_Long() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("longValue", 123456L);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("longValue", 987654L);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
Map<String, Object> variables3 = new HashMap<String, Object>();
variables3.put("longValue", 555555L);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables3);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueGreaterThan("longValue", 123456L);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertEquals(2, query.count());
for (VariableInstance var : result) {
assertEquals("longValue", var.getName());
assertEquals("long", var.getTypeName());
if (var.getValue().equals(555555L)) {
assertEquals(555555L, var.getValue());
} else if (var.getValue().equals(987654L)) {
assertEquals(987654L, var.getValue());
} else {
fail("A non expected value occured: " + var.getValue());
}
}
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableValueEqualsWihtoutAnyResult.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueEqualsWihtoutAnyResult() {
// given
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "test");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueEquals("stringVar", "notFoundValue");
// then
List<VariableInstance> result = query.list();
assertTrue(result.isEmpty());
assertEquals(0, query.count());
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableLessThan_Short.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableLessThan_Short() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("shortValue", (short) 123);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("shortValue", (short) 999);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
Map<String, Object> variables3 = new HashMap<String, Object>();
variables3.put("shortValue", (short) 555);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables3);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueLessThan("shortValue", (short) 999);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertEquals(2, query.count());
for (VariableInstance var : result) {
assertEquals("shortValue", var.getName());
assertEquals("short", var.getTypeName());
if (var.getValue().equals((short) 123)) {
assertEquals((short) 123, var.getValue());
} else if (var.getValue().equals((short) 555)) {
assertEquals((short) 555, var.getValue());
} else {
fail("A non expected value occured: " + var.getValue());
}
}
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByCaseActivityInstanceIds.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testQueryByCaseActivityInstanceIds() {
CaseInstance instance1 = caseService.withCaseDefinitionByKey("oneTaskCase").setVariable("aVariableName", "abc").create();
CaseInstance instance2 = caseService.withCaseDefinitionByKey("oneTaskCase").setVariable("anotherVariableName", "xyz").create();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
query.activityInstanceIdIn(instance1.getId(), instance2.getId()).orderByVariableName().asc();
List<VariableInstance> result = query.list();
assertEquals(2, result.size());
for (VariableInstance variableInstance : result) {
if (variableInstance.getName().equals("aVariableName")) {
assertEquals("aVariableName", variableInstance.getName());
assertEquals("abc", variableInstance.getValue());
} else if (variableInstance.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variableInstance.getName());
assertEquals("xyz", variableInstance.getValue());
} else {
fail("Unexpected variable: " + variableInstance.getName());
}
}
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByNameAndVariableValueLessThan_String.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueLessThan_String() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("stringVar", "a");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("stringVar", "b");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
Map<String, Object> variables3 = new HashMap<String, Object>();
variables3.put("stringVar", "c");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables3);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueLessThan("stringVar", "c");
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertEquals(2, query.count());
for (VariableInstance var : result) {
assertEquals("stringVar", var.getName());
assertEquals("string", var.getTypeName());
if (var.getValue().equals("a")) {
assertEquals("a", var.getValue());
} else if (var.getValue().equals("b")) {
assertEquals("b", var.getValue());
} else {
fail("A non expected value occured: " + var.getValue());
}
}
}
Aggregations