Search in sources :

Example 36 with HistoricDetail

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricVariableInstanceForSingleActivityInstantiation.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricVariableInstanceForSingleActivityInstantiation() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task1").setVariable("aVar", "aValue").execute();
    ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
    // then
    HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult();
    assertNotNull(historicVariable);
    assertEquals(instance.getId(), historicVariable.getProcessInstanceId());
    assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId());
    assertEquals("aVar", historicVariable.getName());
    assertEquals("aValue", historicVariable.getValue());
    HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.getId()).singleResult();
    assertEquals(instance.getId(), historicDetail.getProcessInstanceId());
    assertNotNull(historicDetail);
    // TODO: fix if this is not ok due to CAM-3886
    assertNull(historicDetail.getActivityInstanceId());
    assertTrue(historicDetail instanceof HistoricVariableUpdate);
    assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
    assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 37 with HistoricDetail

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

the class ProcessInstantiationAtActivitiesHistoryTest method testHistoricVariableInstanceSetOnProcessInstance.

@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS)
public void testHistoricVariableInstanceSetOnProcessInstance() {
    // when
    ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").setVariable("aVar", "aValue").startBeforeActivity("task1").execute();
    ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId());
    // then
    HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult();
    assertNotNull(historicVariable);
    assertEquals(instance.getId(), historicVariable.getProcessInstanceId());
    assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId());
    assertEquals("aVar", historicVariable.getName());
    assertEquals("aValue", historicVariable.getValue());
    HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.getId()).singleResult();
    assertEquals(instance.getId(), historicDetail.getProcessInstanceId());
    assertNotNull(historicDetail);
    // TODO: fix if this is not ok due to CAM-3886
    assertEquals(instance.getId(), historicDetail.getActivityInstanceId());
    assertTrue(historicDetail instanceof HistoricVariableUpdate);
    assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName());
    assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue());
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) ActivityInstance(org.camunda.bpm.engine.runtime.ActivityInstance) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 38 with HistoricDetail

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

the class RuntimeServiceTest method checkHistoricVariableUpdateEntity.

private void checkHistoricVariableUpdateEntity(String variableName, String processInstanceId) {
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        boolean deletedVariableUpdateFound = false;
        List<HistoricDetail> resultSet = historyService.createHistoricDetailQuery().processInstanceId(processInstanceId).list();
        for (HistoricDetail currentHistoricDetail : resultSet) {
            assertTrue(currentHistoricDetail instanceof HistoricDetailVariableInstanceUpdateEntity);
            HistoricDetailVariableInstanceUpdateEntity historicVariableUpdate = (HistoricDetailVariableInstanceUpdateEntity) currentHistoricDetail;
            if (historicVariableUpdate.getName().equals(variableName)) {
                if (historicVariableUpdate.getValue() == null) {
                    if (deletedVariableUpdateFound) {
                        fail("Mismatch: A HistoricVariableUpdateEntity with a null value already found");
                    } else {
                        deletedVariableUpdateFound = true;
                    }
                }
            }
        }
        assertTrue(deletedVariableUpdateFound);
    }
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricDetailVariableInstanceUpdateEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)

Example 39 with HistoricDetail

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

the class HistoricVariableInstanceScopeTest method testCmmnActivityInstanceIdOnCaseExecution.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnCaseExecution() {
    // given
    caseService.createCaseInstanceByKey("oneTaskCase");
    String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    caseService.withCaseExecution(taskExecutionId).setVariableLocal("foo", "bar").execute();
    // then
    HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("foo").singleResult();
    assertNotNull(variable);
    assertEquals(taskExecutionId, variable.getActivityInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricDetail variableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variable.getId()).singleResult();
        assertEquals(taskExecutionId, variableDetail.getActivityInstanceId());
    }
}
Also used : HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 40 with HistoricDetail

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

the class HistoricVariableInstanceScopeTest method testCmmnActivityInstanceIdOnCaseInstance.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn" })
public void testCmmnActivityInstanceIdOnCaseInstance() {
    // given
    CaseInstance caseInstance = caseService.createCaseInstanceByKey("oneTaskCase");
    String taskExecutionId = caseService.createCaseExecutionQuery().activityId("PI_HumanTask_1").singleResult().getId();
    // when
    caseService.withCaseExecution(taskExecutionId).setVariable("foo", "bar").execute();
    // then
    HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("foo").singleResult();
    assertNotNull(variable);
    assertEquals(caseInstance.getId(), variable.getActivityInstanceId());
    if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
        HistoricDetail variableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variable.getId()).singleResult();
        assertEquals(taskExecutionId, variableDetail.getActivityInstanceId());
    }
}
Also used : CaseInstance(org.camunda.bpm.engine.runtime.CaseInstance) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)40 Deployment (org.camunda.bpm.engine.test.Deployment)23 Test (org.junit.Test)20 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)14 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)14 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)14 Task (org.camunda.bpm.engine.task.Task)13 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)12 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)10 HashMap (java.util.HashMap)7 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)7 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)6 ArrayList (java.util.ArrayList)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricDetailVariableInstanceUpdateEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity)3 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HistoricDetailQuery (org.camunda.bpm.engine.history.HistoricDetailQuery)2 HistoricFormProperty (org.camunda.bpm.engine.history.HistoricFormProperty)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2