use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class HistoricVariableInstanceScopeTest method testInputMappings.
@Deployment
public void testInputMappings() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId);
String theService1Id = activityInstanceQuery.activityId("theService1").singleResult().getId();
String theService2Id = activityInstanceQuery.activityId("theService2").singleResult().getId();
String theTaskId = activityInstanceQuery.activityId("theTask").singleResult().getId();
// when (1)
HistoricVariableInstance firstVariable = historyService.createHistoricVariableInstanceQuery().variableName("firstInputVariable").singleResult();
// then (1)
assertEquals(theService1Id, firstVariable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail firstVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(firstVariable.getId()).singleResult();
assertEquals(theService1Id, firstVariableDetail.getActivityInstanceId());
}
// when (2)
HistoricVariableInstance secondVariable = historyService.createHistoricVariableInstanceQuery().variableName("secondInputVariable").singleResult();
// then (2)
assertEquals(theService2Id, secondVariable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail secondVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(secondVariable.getId()).singleResult();
assertEquals(theService2Id, secondVariableDetail.getActivityInstanceId());
}
// when (3)
HistoricVariableInstance thirdVariable = historyService.createHistoricVariableInstanceQuery().variableName("thirdInputVariable").singleResult();
// then (3)
assertEquals(theTaskId, thirdVariable.getActivityInstanceId());
if (processEngineConfiguration.getHistoryLevel().getId() > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) {
HistoricDetail thirdVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(thirdVariable.getId()).singleResult();
assertEquals(theTaskId, thirdVariableDetail.getActivityInstanceId());
}
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class FullHistoryTest method testDisableCustomObjectDeserialization.
@Test
public void testDisableCustomObjectDeserialization() {
Task newTask = taskService.newTask();
taskService.saveTask(newTask);
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("customSerializable", new CustomSerializable());
variables.put("failingSerializable", new FailingSerializable());
taskService.setVariables(newTask.getId(), variables);
List<HistoricDetail> results = historyService.createHistoricDetailQuery().disableBinaryFetching().disableCustomObjectDeserialization().variableUpdates().list();
// both variables are not deserialized, but their serialized values are available
assertEquals(2, results.size());
for (HistoricDetail update : results) {
HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) update;
assertNull(variableUpdate.getErrorMessage());
ObjectValue typedValue = (ObjectValue) variableUpdate.getTypedValue();
assertNotNull(typedValue);
assertFalse(typedValue.isDeserialized());
// cannot access the deserialized value
try {
typedValue.getValue();
} catch (IllegalStateException e) {
Assert.assertThat(e.getMessage(), CoreMatchers.containsString("Object is not deserialized"));
}
assertNotNull(typedValue.getValueSerialized());
}
taskService.deleteTask(newTask.getId(), true);
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class FullHistoryTest method testBinaryFetchingEnabled.
@Test
public void testBinaryFetchingEnabled() {
// by default, binary fetching is enabled
Task newTask = taskService.newTask();
taskService.saveTask(newTask);
String variableName = "binaryVariableName";
taskService.setVariable(newTask.getId(), variableName, "some bytes".getBytes());
HistoricDetail result = historyService.createHistoricDetailQuery().variableUpdates().singleResult();
assertNotNull(((HistoricVariableUpdate) result).getValue());
taskService.deleteTask(newTask.getId(), true);
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class FullHistoryTest method testHistoricFormPropertiesOnReEnteringActivity.
/**
* Test created to validate ACT-621 fix.
*/
@Test
@Deployment
public void testHistoricFormPropertiesOnReEnteringActivity() {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("comeBack", Boolean.TRUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("HistoricFormPropertiesProcess", variables);
assertNotNull(processInstance);
// Submit form on task
Map<String, String> data = new HashMap<String, String>();
data.put("formProp1", "Property value");
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
formService.submitTaskFormData(task.getId(), data);
// Historic property should be available
List<HistoricDetail> details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
assertNotNull(details);
assertEquals(1, details.size());
// Task should be active in the same activity as the previous one
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
formService.submitTaskFormData(task.getId(), data);
details = historyService.createHistoricDetailQuery().formProperties().processInstanceId(processInstance.getId()).list();
assertNotNull(details);
assertEquals(2, details.size());
// Should have 2 different historic activity instance ID's, with the same activityId
Assert.assertNotSame(details.get(0).getActivityInstanceId(), details.get(1).getActivityInstanceId());
HistoricActivityInstance historicActInst1 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(0).getActivityInstanceId()).singleResult();
HistoricActivityInstance historicActInst2 = historyService.createHistoricActivityInstanceQuery().activityInstanceId(details.get(1).getActivityInstanceId()).singleResult();
assertEquals(historicActInst1.getActivityId(), historicActInst2.getActivityId());
}
use of org.camunda.bpm.engine.history.HistoricDetail in project camunda-bpm-platform by camunda.
the class FullHistoryTest method testHistoricDetailQueryByNonExistingId.
@Test
public void testHistoricDetailQueryByNonExistingId() {
Task newTask = taskService.newTask();
taskService.saveTask(newTask);
String variableName = "someName";
String variableValue = "someValue";
taskService.setVariable(newTask.getId(), variableName, variableValue);
HistoricDetail result = historyService.createHistoricDetailQuery().detailId("non-existing").singleResult();
assertNull(result);
taskService.deleteTask(newTask.getId(), true);
}
Aggregations