use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method testMigrateHistoryVariableInstanceMultiInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testMigrateHistoryVariableInstanceMultiInstance() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_SUBPROCESS_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_SUBPROCESS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapEqualActivities().build();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
List<HistoricVariableInstance> migratedVariables = historyService.createHistoricVariableInstanceQuery().list();
// 3 loop counter + nrOfInstance + nrOfActiveInstances + nrOfCompletedInstances
Assert.assertEquals(6, migratedVariables.size());
for (HistoricVariableInstance variable : migratedVariables) {
assertEquals(targetDefinition.getKey(), variable.getProcessDefinitionKey());
assertEquals(targetDefinition.getId(), variable.getProcessDefinitionId());
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method testMigrateHistoryVariableInstance.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_AUDIT)
public void testMigrateHistoryVariableInstance() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).changeElementId(ProcessModels.PROCESS_KEY, "new" + ProcessModels.PROCESS_KEY));
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.getId());
runtimeService.setVariable(processInstance.getId(), "test", 3537);
HistoricVariableInstance instance = historyService.createHistoricVariableInstanceQuery().singleResult();
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapActivities("userTask", "userTask").build();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
HistoricVariableInstance migratedInstance = historyService.createHistoricVariableInstanceQuery().singleResult();
assertEquals(targetDefinition.getKey(), migratedInstance.getProcessDefinitionKey());
assertEquals(targetDefinition.getId(), migratedInstance.getProcessDefinitionId());
assertEquals(instance.getActivityInstanceId(), migratedInstance.getActivityInstanceId());
assertEquals(instance.getExecutionId(), migratedInstance.getExecutionId());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class DeserializableVariableTest method testVariableDeserializationOnProcessApplicationRestart.
@Test
@OperateOnDeployment("clientDeployment")
public void testVariableDeserializationOnProcessApplicationRestart() {
// given
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testDeserializeVariable");
// when
Assert.assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult());
runtimeService.restartProcessInstances(pi.getProcessDefinitionId()).startAfterActivity("servicetask1").processInstanceIds(pi.getId()).execute();
// then
// Since the variable retrieval is done outside the Process Application Context as well,
// custom object deserialization is disabled and a null check is performed
List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery().disableCustomObjectDeserialization().list();
for (HistoricVariableInstance variable : variableInstances) {
if (variable.getProcessInstanceId() != pi.getId() && variable instanceof HistoricVariableInstanceEntity) {
Assert.assertNotNull(((HistoricVariableInstanceEntity) variable).getByteArrayValue());
}
}
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class CreateProcessInstanceWithVariableTest method testCreateProcessInstanceWithVariable.
@ScenarioUnderTest("initProcessInstance.1")
@Test
public void testCreateProcessInstanceWithVariable() {
// then
ProcessInstance processInstance = engineRule.getRuntimeService().createProcessInstanceQuery().processInstanceBusinessKey("process").singleResult();
List<HistoricVariableInstance> variables = engineRule.getHistoryService().createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list();
assertEquals(1, variables.size());
assertEquals("foo", variables.get(0).getName());
assertEquals("bar", variables.get(0).getValue());
}
use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.
the class TaskListenerTest method testScriptListener.
@Test
@Deployment
public void testScriptListener() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "create"));
taskService.setAssignee(task.getId(), "test");
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "assignment"));
taskService.complete(task.getId());
assertTrue((Boolean) runtimeService.getVariable(processInstance.getId(), "complete"));
task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
runtimeService.deleteProcessInstance(processInstance.getId(), "test");
if (processEngineConfiguration.getHistoryLevel().getId() >= HISTORYLEVEL_AUDIT) {
HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("delete").singleResult();
assertNotNull(variable);
assertTrue((Boolean) variable.getValue());
}
}
Aggregations