Search in sources :

Example 41 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.

the class CompensateEventTest method testCompensateActivityRefInEventSubprocess.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationInEventSubProcessActivityRef.bpmn20.xml" })
public void testCompensateActivityRefInEventSubprocess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");
    assertProcessEnded(processInstance.getId());
    HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("undoBookSecondHotel");
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals("undoBookSecondHotel", historicVariableInstanceQuery.list().get(0).getVariableName());
        assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue());
        assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookFlight").count());
        assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookHotel").count());
    }
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 42 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.

the class CompensateEventTest method testCompensateActivityRefTriggeredByEventSubprocessInSubProcess.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationTriggeredByEventSubProcessInSubProcessActivityRef.bpmn20.xml" })
public void testCompensateActivityRefTriggeredByEventSubprocessInSubProcess() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("compensateProcess");
    assertProcessEnded(processInstance.getId());
    HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookHotel");
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals("undoBookHotel", historicVariableInstanceQuery.list().get(0).getVariableName());
        assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue());
        assertEquals(0, historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).variableName("undoBookFlight").count());
    }
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 43 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceManager method deleteHistoricVariableInstancesByTaskId.

public void deleteHistoricVariableInstancesByTaskId(String taskId) {
    if (isHistoryEnabled()) {
        HistoricVariableInstanceQuery historicProcessVariableQuery = new HistoricVariableInstanceQueryImpl().taskIdIn(taskId);
        List<HistoricVariableInstance> historicProcessVariables = historicProcessVariableQuery.list();
        for (HistoricVariableInstance historicProcessVariable : historicProcessVariables) {
            ((HistoricVariableInstanceEntity) historicProcessVariable).delete();
        }
    }
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) HistoricVariableInstanceQueryImpl(org.camunda.bpm.engine.impl.HistoricVariableInstanceQueryImpl) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance)

Example 44 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.

the class AsyncEndEventTest method testAsyncEndEventListeners.

@Deployment
public void testAsyncEndEventListeners() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("asyncEndEvent");
    long count = runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).active().count();
    Assert.assertNull(runtimeService.getVariable(pi.getId(), "listener"));
    Assert.assertEquals(1, runtimeService.createExecutionQuery().activityId("endEvent").count());
    Assert.assertEquals(1, count);
    // as we are standing at the end event, we execute it.
    executeAvailableJobs();
    count = runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).active().count();
    Assert.assertEquals(0, count);
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        // after the end event we have a event listener
        HistoricVariableInstanceQuery name = historyService.createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).variableName("listener");
        Assert.assertNotNull(name);
        Assert.assertEquals("listener invoked", name.singleResult().getValue());
    }
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 45 with HistoricVariableInstanceQuery

use of org.camunda.bpm.engine.history.HistoricVariableInstanceQuery in project camunda-bpm-platform by camunda.

the class AsyncEndEventTest method testMultipleAsyncEndEvents.

@Deployment
public void testMultipleAsyncEndEvents() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("multipleAsyncEndEvent");
    assertEquals(1, runtimeService.createProcessInstanceQuery().count());
    // should stop at both end events
    List<Job> jobs = managementService.createJobQuery().withRetriesLeft().list();
    assertEquals(2, jobs.size());
    // execute one of the end events
    managementService.executeJob(jobs.get(0).getId());
    jobs = managementService.createJobQuery().withRetriesLeft().list();
    assertEquals(1, jobs.size());
    // execute the second one
    managementService.executeJob(jobs.get(0).getId());
    // assert that we have finished our instance now
    assertEquals(0, runtimeService.createProcessInstanceQuery().count());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_ACTIVITY) {
        // after the end event we have a event listener
        HistoricVariableInstanceQuery name = historyService.createHistoricVariableInstanceQuery().processInstanceId(pi.getId()).variableName("message");
        Assert.assertNotNull(name);
        Assert.assertEquals(true, name.singleResult().getValue());
    }
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Job(org.camunda.bpm.engine.runtime.Job) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)48 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)21 Deployment (org.camunda.bpm.engine.test.Deployment)21 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)18 Task (org.camunda.bpm.engine.task.Task)8 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)3 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)3 ArrayList (java.util.ArrayList)2 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)2 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)2 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HistoricVariableInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricVariableInstanceQueryImpl)1 CountResultDto (org.camunda.bpm.engine.rest.dto.CountResultDto)1 HistoricVariableInstanceDto (org.camunda.bpm.engine.rest.dto.history.HistoricVariableInstanceDto)1 Job (org.camunda.bpm.engine.runtime.Job)1 SerializableVariable (org.camunda.bpm.engine.test.history.SerializableVariable)1