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());
}
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());
}
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());
}
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);
}
Aggregations