use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByTaskIdWithoutAnyResult.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByTaskIdWithoutAnyResult() {
// given
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "test");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
taskService.setVariableLocal(task.getId(), "taskVariable", "aCustomValue");
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().taskIdIn("aTaskId");
// 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_Integer.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableLessThan_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);
Map<String, Object> variables3 = new HashMap<String, Object>();
variables3.put("intValue", 9876);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables3);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueLessThan("intValue", 9876);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
assertEquals(2, query.count());
for (VariableInstance var : result) {
assertEquals("intValue", var.getName());
assertEquals("integer", var.getTypeName());
if (var.getValue().equals(5555)) {
assertEquals(5555, var.getValue());
} else if (var.getValue().equals(1234)) {
assertEquals(1234, 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 testQueryByNameAndVariableValueNotEquals_Double.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByNameAndVariableValueNotEquals_Double() {
// given
Map<String, Object> variables1 = new HashMap<String, Object>();
variables1.put("doubleValue", 123.456);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1);
Map<String, Object> variables2 = new HashMap<String, Object>();
variables2.put("doubleValue", 654.321);
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2);
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().variableValueNotEquals("doubleValue", 654.321);
// then
List<VariableInstance> result = query.list();
assertFalse(result.isEmpty());
assertEquals(1, result.size());
assertEquals(1, query.count());
VariableInstance var = result.get(0);
assertEquals("doubleValue", var.getName());
assertEquals(123.456, var.getValue());
assertEquals("double", var.getTypeName());
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testQueryByExecutionIdWithoutAnyResult.
@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml" })
public void testQueryByExecutionIdWithoutAnyResult() {
// given
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("stringVar", "test");
runtimeService.startProcessInstanceByKey("oneTaskProcess", variables);
runtimeService.startProcessInstanceByKey("oneTaskProcess");
// when
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().executionIdIn("anExecutionId");
// 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 TaskAuthorizationTest method testProcessTaskRemoveVariableWithReadPermissionOnTask.
public void testProcessTaskRemoveVariableWithReadPermissionOnTask() {
// given
startProcessInstanceByKey(PROCESS_KEY, getVariables());
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.removeVariable(taskId, VARIABLE_NAME);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
verifyQueryResults(query, 0);
enableAuthorization();
}
Aggregations