Search in sources :

Example 26 with HistoricVariableUpdate

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

the class FullHistoryTest method testHistoricDetailQueryMixed.

@Test
@Deployment
public void testHistoricDetailQueryMixed() throws Exception {
    Map<String, String> formProperties = new HashMap<String, String>();
    formProperties.put("formProp1", "activiti rocks!");
    formProperties.put("formProp2", "12345");
    ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("historicDetailMixed").singleResult();
    ProcessInstance processInstance = formService.submitStartFormData(procDef.getId(), formProperties);
    List<HistoricDetail> details = historyService.createHistoricDetailQuery().processInstanceId(processInstance.getId()).orderByVariableName().asc().list();
    assertEquals(4, details.size());
    assertTrue(details.get(0) instanceof HistoricFormProperty);
    HistoricFormProperty formProp1 = (HistoricFormProperty) details.get(0);
    assertEquals("formProp1", formProp1.getPropertyId());
    assertEquals("activiti rocks!", formProp1.getPropertyValue());
    assertTrue(details.get(1) instanceof HistoricFormProperty);
    HistoricFormProperty formProp2 = (HistoricFormProperty) details.get(1);
    assertEquals("formProp2", formProp2.getPropertyId());
    assertEquals("12345", formProp2.getPropertyValue());
    assertTrue(details.get(2) instanceof HistoricVariableUpdate);
    HistoricVariableUpdate varUpdate1 = (HistoricVariableUpdate) details.get(2);
    assertEquals("variable1", varUpdate1.getVariableName());
    assertEquals("activiti rocks!", varUpdate1.getValue());
    // This variable should be of type LONG since this is defined in the process-definition
    assertTrue(details.get(3) instanceof HistoricVariableUpdate);
    HistoricVariableUpdate varUpdate2 = (HistoricVariableUpdate) details.get(3);
    assertEquals("variable2", varUpdate2.getVariableName());
    assertEquals(12345L, varUpdate2.getValue());
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) HistoricFormProperty(org.camunda.bpm.engine.history.HistoricFormProperty) HashMap(java.util.HashMap) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 27 with HistoricVariableUpdate

use of org.camunda.bpm.engine.history.HistoricVariableUpdate 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 28 with HistoricVariableUpdate

use of org.camunda.bpm.engine.history.HistoricVariableUpdate 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 29 with HistoricVariableUpdate

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

the class UpdateHistoricDetailValueDelegate method execute.

public void execute(DelegateExecution execution) throws Exception {
    HistoryService historyService = execution.getProcessEngineServices().getHistoryService();
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult();
    HistoricVariableUpdate initialUpdate = (HistoricVariableUpdate) historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variableInstance.getId()).orderPartiallyByOccurrence().asc().list().get(0);
    List<String> list = (List<String>) initialUpdate.getValue();
    // implicit update of the list, should not trigger an update
    // of the value since we deal with historic variables
    list.add(NEW_ELEMENT);
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) List(java.util.List)

Aggregations

HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)29 Test (org.junit.Test)19 Deployment (org.camunda.bpm.engine.test.Deployment)13 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)10 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)10 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)8 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)8 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)8 MockHistoricVariableUpdateBuilder (org.camunda.bpm.engine.rest.helper.MockHistoricVariableUpdateBuilder)7 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)6 HashMap (java.util.HashMap)5 Task (org.camunda.bpm.engine.task.Task)5 ObjectValue (org.camunda.bpm.engine.variable.value.ObjectValue)5 FileValue (org.camunda.bpm.engine.variable.value.FileValue)4 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Response (com.jayway.restassured.response.Response)2 HistoryService (org.camunda.bpm.engine.HistoryService)2 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)2 MockObjectValue (org.camunda.bpm.engine.rest.helper.MockObjectValue)2