Search in sources :

Example 6 with VariableInstanceQuery

use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.

the class CaseServiceCaseInstanceTest method testCreateByKeyWithVariables.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCreateByKeyWithVariables() {
    // given a deployed case definition
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("aVariableName", "aVariableValue");
    variables.put("anotherVariableName", 999);
    // when
    CaseInstance caseInstance = caseService.withCaseDefinitionByKey("oneTaskCase").setVariables(variables).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) HashMap(java.util.HashMap) VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 7 with VariableInstanceQuery

use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyVariableInstanceQueryTest method testQueryWithoutTenantId.

public void testQueryWithoutTenantId() {
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
    assertThat(query.count(), is(2L));
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery)

Example 8 with VariableInstanceQuery

use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyVariableInstanceQueryTest method testQueryNoAuthenticatedTenants.

public void testQueryNoAuthenticatedTenants() {
    identityService.setAuthentication("user", null, null);
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
    assertThat(query.count(), is(0L));
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery)

Example 9 with VariableInstanceQuery

use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyVariableInstanceQueryTest method testQueryByTenantId.

public void testQueryByTenantId() {
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().tenantIdIn(TENANT_ONE);
    assertThat(query.count(), is(1L));
    query = runtimeService.createVariableInstanceQuery().tenantIdIn(TENANT_TWO);
    assertThat(query.count(), is(1L));
}
Also used : VariableInstanceQuery(org.camunda.bpm.engine.runtime.VariableInstanceQuery)

Example 10 with VariableInstanceQuery

use of org.camunda.bpm.engine.runtime.VariableInstanceQuery in project camunda-bpm-platform by camunda.

the class MultiTenancyVariableInstanceQueryTest method testQueryDisabledTenantCheck.

public void testQueryDisabledTenantCheck() {
    processEngineConfiguration.setTenantCheckEnabled(false);
    identityService.setAuthentication("user", null, null);
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();
    assertThat(query.count(), is(2L));
}
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