Search in sources :

Example 46 with Execution

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

the class ExecutionQueryTest method testQueryBySignalSubscriptionName.

@Deployment
public void testQueryBySignalSubscriptionName() {
    runtimeService.startProcessInstanceByKey("catchSignal");
    // it finds subscribed instances
    Execution execution = runtimeService.createExecutionQuery().signalEventSubscription("alert").singleResult();
    assertNotNull(execution);
    // test query for nonexisting subscription
    execution = runtimeService.createExecutionQuery().signalEventSubscription("nonExisitng").singleResult();
    assertNull(execution);
    // it finds more than one
    runtimeService.startProcessInstanceByKey("catchSignal");
    assertEquals(2, runtimeService.createExecutionQuery().signalEventSubscription("alert").count());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 47 with Execution

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

the class ExecutionQueryTest method testQueryByIncidentMessage.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/failingProcessCreateOneIncident.bpmn20.xml" })
public void testQueryByIncidentMessage() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("failingProcess");
    executeAvailableJobs();
    List<Incident> incidentList = runtimeService.createIncidentQuery().list();
    assertEquals(1, incidentList.size());
    Incident incident = runtimeService.createIncidentQuery().processInstanceId(processInstance.getId()).singleResult();
    List<Execution> executionList = runtimeService.createExecutionQuery().incidentMessage(incident.getIncidentMessage()).list();
    assertEquals(1, executionList.size());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Incident(org.camunda.bpm.engine.runtime.Incident) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 48 with Execution

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

the class ExecutionQueryTest method testExecutionQueryWithProcessVariable.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testExecutionQueryWithProcessVariable() {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("x", "parent");
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("concurrent", variables);
    List<Execution> concurrentExecutions = runtimeService.createExecutionQuery().processInstanceId(pi.getId()).list();
    assertEquals(3, concurrentExecutions.size());
    for (Execution execution : concurrentExecutions) {
        if (!((ExecutionEntity) execution).isProcessInstanceExecution()) {
            // only the concurrent executions, not the root one, would be cooler to query that directly, see http://jira.codehaus.org/browse/ACT-1373
            runtimeService.setVariableLocal(execution.getId(), "x", "child");
        }
    }
    assertEquals(2, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "child").count());
    assertEquals(1, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).variableValueEquals("x", "parent").count());
    assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueEquals("x", "parent").count());
    assertEquals(3, runtimeService.createExecutionQuery().processInstanceId(pi.getId()).processVariableValueNotEquals("x", "xxx").count());
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 49 with Execution

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

the class ExecutionQueryTest method testExecutionQueryForSuspendedExecutions.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/concurrentExecution.bpmn20.xml" })
public void testExecutionQueryForSuspendedExecutions() {
    List<Execution> suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
    assertEquals(suspendedExecutions.size(), 0);
    for (String instanceId : concurrentProcessInstanceIds) {
        runtimeService.suspendProcessInstanceById(instanceId);
    }
    suspendedExecutions = runtimeService.createExecutionQuery().suspended().list();
    assertEquals(12, suspendedExecutions.size());
    List<Execution> activeExecutions = runtimeService.createExecutionQuery().active().list();
    assertEquals(1, activeExecutions.size());
    for (Execution activeExecution : activeExecutions) {
        assertEquals(activeExecution.getProcessInstanceId(), sequentialProcessInstanceIds.get(0));
    }
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 50 with Execution

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

the class ExecutionQueryTest method testQueryNullVariable.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testQueryNullVariable() throws Exception {
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("nullVar", null);
    ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    vars = new HashMap<String, Object>();
    vars.put("nullVar", "notnull");
    ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    vars = new HashMap<String, Object>();
    vars.put("nullVarLong", "notnull");
    ProcessInstance processInstance3 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    vars = new HashMap<String, Object>();
    vars.put("nullVarDouble", "notnull");
    ProcessInstance processInstance4 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    vars = new HashMap<String, Object>();
    vars.put("nullVarByte", "testbytes".getBytes());
    ProcessInstance processInstance5 = runtimeService.startProcessInstanceByKey("oneTaskProcess", vars);
    // Query on null value, should return one value
    ExecutionQuery query = runtimeService.createExecutionQuery().variableValueEquals("nullVar", null);
    List<Execution> executions = query.list();
    Assert.assertNotNull(executions);
    Assert.assertEquals(1, executions.size());
    Assert.assertEquals(processInstance1.getId(), executions.get(0).getId());
    // Test NOT_EQUALS null
    Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVar", null).count());
    Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarLong", null).count());
    Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarDouble", null).count());
    // When a byte-array refrence is present, the variable is not considered null
    Assert.assertEquals(1, runtimeService.createExecutionQuery().variableValueNotEquals("nullVarByte", null).count());
    // All other variable queries with null should throw exception
    try {
        runtimeService.createExecutionQuery().variableValueGreaterThan("nullVar", null);
        fail("Excetion expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("Booleans and null cannot be used in 'greater than' condition", ae.getMessage());
    }
    try {
        runtimeService.createExecutionQuery().variableValueGreaterThanOrEqual("nullVar", null);
        fail("Excetion expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("Booleans and null cannot be used in 'greater than or equal' condition", ae.getMessage());
    }
    try {
        runtimeService.createExecutionQuery().variableValueLessThan("nullVar", null);
        fail("Excetion expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("Booleans and null cannot be used in 'less than' condition", ae.getMessage());
    }
    try {
        runtimeService.createExecutionQuery().variableValueLessThanOrEqual("nullVar", null);
        fail("Excetion expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("Booleans and null cannot be used in 'less than or equal' condition", ae.getMessage());
    }
    try {
        runtimeService.createExecutionQuery().variableValueLike("nullVar", null);
        fail("Excetion expected");
    } catch (ProcessEngineException ae) {
        assertTextPresent("Booleans and null cannot be used in 'like' condition", ae.getMessage());
    }
    runtimeService.deleteProcessInstance(processInstance1.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance2.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance3.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance4.getId(), "test");
    runtimeService.deleteProcessInstance(processInstance5.getId(), "test");
}
Also used : Execution(org.camunda.bpm.engine.runtime.Execution) HashMap(java.util.HashMap) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) ExecutionQuery(org.camunda.bpm.engine.runtime.ExecutionQuery) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

Execution (org.camunda.bpm.engine.runtime.Execution)279 Deployment (org.camunda.bpm.engine.test.Deployment)188 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)143 Task (org.camunda.bpm.engine.task.Task)99 Test (org.junit.Test)95 HashMap (java.util.HashMap)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)33 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)23 TaskQuery (org.camunda.bpm.engine.task.TaskQuery)22 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)20 ThrowErrorDelegate.leaveExecution (org.camunda.bpm.engine.test.bpmn.event.error.ThrowErrorDelegate.leaveExecution)18 ExecutionQuery (org.camunda.bpm.engine.runtime.ExecutionQuery)17 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)15 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)14 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)14 DelegateExecution (org.camunda.bpm.engine.delegate.DelegateExecution)13 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)12 ArrayList (java.util.ArrayList)11