Search in sources :

Example 11 with HistoricVariableInstanceQuery

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

the class HistoricVariableInstanceAuthorizationTest method testQueryWithReadHistoryPermissionOnAnyProcessDefinition.

public void testQueryWithReadHistoryPermissionOnAnyProcessDefinition() {
    // given
    startProcessInstanceByKey(PROCESS_KEY, getVariables());
    startProcessInstanceByKey(PROCESS_KEY, getVariables());
    startProcessInstanceByKey(PROCESS_KEY, getVariables());
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY, getVariables());
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY, getVariables());
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY, getVariables());
    startProcessInstanceByKey(MESSAGE_START_PROCESS_KEY, getVariables());
    createGrantAuthorization(PROCESS_DEFINITION, ANY, userId, READ_HISTORY);
    // when
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    // then
    verifyQueryResults(query, 7);
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)

Example 12 with HistoricVariableInstanceQuery

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

the class MultiTenancyHistoricVariableInstanceQueryTest method testQueryNoAuthenticatedTenants.

public void testQueryNoAuthenticatedTenants() {
    identityService.setAuthentication("user", null, null);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertThat(query.count(), is(0L));
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)

Example 13 with HistoricVariableInstanceQuery

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

the class CompensateEventTest method testCompensateInEventSubprocess.

/**
 * enable test case when bug is fixed
 *
 * @see https://app.camunda.com/jira/browse/CAM-4304
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationInEventSubProcess.bpmn20.xml" })
public void testCompensateInEventSubprocess() {
    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());
        historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("undoBookFlight");
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals(5, historicVariableInstanceQuery.list().get(0).getValue());
        historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("undoBookHotel");
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals(5, historicVariableInstanceQuery.list().get(0).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 14 with HistoricVariableInstanceQuery

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

the class CompensateEventTest method testConcurrentScopeCompensation.

@Deployment
public void testConcurrentScopeCompensation() {
    // given a process instance with two concurrent tasks, one of which is waiting
    // before throwing compensation
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("concurrentScopeCompensation");
    Task beforeCompensationTask = taskService.createTaskQuery().taskDefinitionKey("beforeCompensationTask").singleResult();
    Task concurrentTask = taskService.createTaskQuery().taskDefinitionKey("concurrentTask").singleResult();
    // when throwing compensation such that two subprocesses are compensated
    taskService.complete(beforeCompensationTask.getId());
    // then both compensation handlers have been executed
    if (processEngineConfiguration.getHistoryLevel().getId() >= ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricVariableInstanceQuery historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("compensateScope1Task");
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals(1, historicVariableInstanceQuery.list().get(0).getValue());
        historicVariableInstanceQuery = historyService.createHistoricVariableInstanceQuery().variableName("compensateScope2Task");
        assertEquals(1, historicVariableInstanceQuery.count());
        assertEquals(1, historicVariableInstanceQuery.list().get(0).getValue());
    }
    // and after completing the concurrent task, the process instance ends successfully
    taskService.complete(concurrentTask.getId());
    assertProcessEnded(processInstance.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 15 with HistoricVariableInstanceQuery

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

the class CompensateEventTest method testCompensateActivityRefTriggeredByEventSubprocess.

@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/event/compensate/CompensateEventTest.testCompensationTriggeredByEventSubProcessActivityRef.bpmn20.xml" })
public void testCompensateActivityRefTriggeredByEventSubprocess() {
    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)

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