Search in sources :

Example 1 with VariableInstanceQuery

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;
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) CountResultDto(org.camunda.bpm.engine.rest.dto.CountResultDto) ProcessEngine(org.camunda.bpm.engine.ProcessEngine)

Example 2 with VariableInstanceQuery

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;
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery)

Example 3 with VariableInstanceQuery

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();
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 4 with VariableInstanceQuery

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();
}
Also used : Task(org.camunda.bpm.engine.task.Task) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 5 with VariableInstanceQuery

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());
        }
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)347 Deployment (org.camunda.bpm.engine.test.Deployment)206 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)90 Test (org.junit.Test)79 HashMap (java.util.HashMap)72 Matchers.containsString (org.hamcrest.Matchers.containsString)28 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)20 Task (org.camunda.bpm.engine.task.Task)18 TaskServiceImpl (org.camunda.bpm.engine.impl.TaskServiceImpl)12 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)10 RuntimeServiceImpl (org.camunda.bpm.engine.impl.RuntimeServiceImpl)8 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)7 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)6 MySpecialTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.MySpecialTaskListener)6 MyTaskListener (org.camunda.bpm.engine.test.cmmn.tasklistener.util.MyTaskListener)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)4 ArrayList (java.util.ArrayList)3 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)3