Search in sources :

Example 51 with VariableInstanceQuery

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

Example 52 with VariableInstanceQuery

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

Example 53 with VariableInstanceQuery

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

Example 54 with VariableInstanceQuery

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

Example 55 with VariableInstanceQuery

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

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