use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceRestServiceImpl method queryVariableInstancesCount.
@Override
public CountResultDto queryVariableInstancesCount(VariableInstanceQueryDto queryDto) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
VariableInstanceQuery query = queryDto.toQuery(engine);
long count = query.count();
CountResultDto result = new CountResultDto();
result.setCount(count);
return result;
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class VariableInstanceRestServiceQueryTest method setUpMockVariableInstanceQuery.
private VariableInstanceQuery setUpMockVariableInstanceQuery(List<VariableInstance> mockedInstances) {
VariableInstanceQuery sampleInstanceQuery = mock(VariableInstanceQuery.class);
when(sampleInstanceQuery.list()).thenReturn(mockedInstances);
when(sampleInstanceQuery.count()).thenReturn((long) mockedInstances.size());
when(processEngine.getRuntimeService().createVariableInstanceQuery()).thenReturn(sampleInstanceQuery);
return sampleInstanceQuery;
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testScriptIoMappingExecutesCommandAfterUserCompletesTask.
@Deployment
public void testScriptIoMappingExecutesCommandAfterUserCompletesTask() {
// given
String processInstanceId = startProcessInstanceByKey(DEFAULT_PROCESS_KEY).getId();
String taskId = selectSingleTask().getId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query.variableName("userId").singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query.variableName("count").singleResult();
assertNotNull(variableCount);
assertEquals(1l, variableCount.getValue());
assertEquals(2, runtimeService.createProcessInstanceQuery().count());
enableAuthorization();
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class DelegationAuthorizationTest method testScriptTaskListenerExecutesQueryAfterUserCompletesTask.
@Deployment
public void testScriptTaskListenerExecutesQueryAfterUserCompletesTask() {
// given
startProcessInstancesByKey(DEFAULT_PROCESS_KEY, 5);
Task task = selectAnyTask();
String taskId = task.getId();
String processInstanceId = task.getProcessInstanceId();
createGrantAuthorization(TASK, taskId, userId, UPDATE);
// when
taskService.complete(taskId);
// then
disableAuthorization();
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().processInstanceIdIn(processInstanceId);
VariableInstance variableUser = query.variableName("userId").singleResult();
assertNotNull(variableUser);
assertEquals(userId, variableUser.getValue());
VariableInstance variableCount = query.variableName("count").singleResult();
assertNotNull(variableCount);
assertEquals(5l, variableCount.getValue());
enableAuthorization();
}
use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.
the class CaseServiceCaseInstanceTest method testCreateByKeyWithVariable.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCreateByKeyWithVariable() {
// given a deployed case definition
// when
CaseInstance caseInstance = caseService.withCaseDefinitionByKey("oneTaskCase").setVariable("aVariableName", "aVariableValue").setVariable("anotherVariableName", 999).create();
// then
assertNotNull(caseInstance);
// there should exist two variables
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
List<VariableInstance> result = query.caseInstanceIdIn(caseInstance.getId()).orderByVariableName().asc().list();
assertFalse(result.isEmpty());
assertEquals(2, result.size());
for (VariableInstance variableInstance : result) {
if (variableInstance.getName().equals("aVariableName")) {
assertEquals("aVariableName", variableInstance.getName());
assertEquals("aVariableValue", variableInstance.getValue());
} else if (variableInstance.getName().equals("anotherVariableName")) {
assertEquals("anotherVariableName", variableInstance.getName());
assertEquals(999, variableInstance.getValue());
} else {
fail("Unexpected variable: " + variableInstance.getName());
}
}
}
Aggregations