use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MultiTenancyProcessInstantiationTest method testRestartProcessInstanceSyncWithTenantId.
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testRestartProcessInstanceSyncWithTenantId() {
// given
ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS);
identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE));
// when
runtimeService.restartProcessInstances(processInstance.getProcessDefinitionId()).startBeforeActivity("userTask").processInstanceIds(processInstance.getId()).execute();
// then
ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.getProcessDefinitionId()).singleResult();
assertNotNull(restartedInstance);
assertEquals(restartedInstance.getTenantId(), TENANT_ONE);
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class BatchSuspensionTest method shouldCreateUserOperationLogForBatchActivation.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void shouldCreateUserOperationLogForBatchActivation() {
// given
Batch batch = helper.migrateProcessInstancesAsync(1);
managementService.suspendBatchById(batch.getId());
// when
identityService.setAuthenticatedUserId(USER_ID);
managementService.activateBatchById(batch.getId());
identityService.clearAuthentication();
// then
UserOperationLogEntry entry = historyService.createUserOperationLogQuery().singleResult();
assertNotNull(entry);
assertEquals(batch.getId(), entry.getBatchId());
assertEquals(AbstractSetBatchStateCmd.SUSPENSION_STATE_PROPERTY, entry.getProperty());
assertNull(entry.getOrgValue());
assertEquals(SuspensionState.ACTIVE.getName(), entry.getNewValue());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class BatchSuspensionTest method testUserOperationLogQueryByBatchId.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void testUserOperationLogQueryByBatchId() {
// given
Batch batch1 = helper.migrateProcessInstancesAsync(1);
Batch batch2 = helper.migrateProcessInstancesAsync(1);
// when
identityService.setAuthenticatedUserId(USER_ID);
managementService.suspendBatchById(batch1.getId());
managementService.suspendBatchById(batch2.getId());
managementService.activateBatchById(batch1.getId());
identityService.clearAuthentication();
// then
UserOperationLogQuery query = historyService.createUserOperationLogQuery().batchId(batch1.getId());
assertEquals(2, query.count());
assertEquals(2, query.list().size());
query = historyService.createUserOperationLogQuery().batchId(batch2.getId());
assertEquals(1, query.count());
assertEquals(1, query.list().size());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationIncidentTest method historicIncidentRemainsOpenAfterMigration.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
@Deployment(resources = { "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess.bpmn", "org/camunda/bpm/engine/test/api/runtime/migration/calledProcess_v2.bpmn" })
public void historicIncidentRemainsOpenAfterMigration() {
// Given we create a new process instance
ProcessDefinition process1 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcess").singleResult();
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceById(process1.getId());
LockedExternalTask task = engineRule.getExternalTaskService().fetchAndLock(1, "foo").topic("foo", 1000L).execute().get(0);
engineRule.getExternalTaskService().handleFailure(task.getId(), "foo", "error", 0, 1000L);
Incident incidentInProcess = engineRule.getRuntimeService().createIncidentQuery().processDefinitionId(process1.getId()).singleResult();
// when
ProcessDefinition process2 = engineRule.getRepositoryService().createProcessDefinitionQuery().processDefinitionKey("calledProcessV2").singleResult();
MigrationPlan migrationPlan = engineRule.getRuntimeService().createMigrationPlan(process1.getId(), process2.getId()).mapEqualActivities().mapActivities("ServiceTask_1p58ywb", "ServiceTask_V2").build();
engineRule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
HistoricIncident historicIncidentAfterMigration = engineRule.getHistoryService().createHistoricIncidentQuery().singleResult();
assertNotNull(historicIncidentAfterMigration);
assertNull(historicIncidentAfterMigration.getEndTime());
assertTrue(historicIncidentAfterMigration.isOpen());
HistoricProcessInstance historicProcessInstanceAfterMigration = engineRule.getHistoryService().createHistoricProcessInstanceQuery().withIncidents().incidentStatus("open").singleResult();
assertNotNull(historicProcessInstanceAfterMigration);
Incident incidentAfterMigration = engineRule.getRuntimeService().createIncidentQuery().incidentId(incidentInProcess.getId()).singleResult();
assertEquals(process2.getId(), incidentAfterMigration.getProcessDefinitionId());
assertEquals("ServiceTask_V2", incidentAfterMigration.getActivityId());
}
use of org.camunda.bpm.engine.test.RequiredHistoryLevel in project camunda-bpm-platform by camunda.
the class MigrationHistoricActivityInstanceTest method testMigrateHistoricSubProcessRename.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_ACTIVITY)
public void testMigrateHistoricSubProcessRename() {
// given
ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS).changeElementId("subProcess", "newSubProcess"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceDefinition.getId(), targetDefinition.getId()).mapActivities("subProcess", "newSubProcess").mapActivities("userTask", "userTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceDefinition.getId());
// when
rule.getRuntimeService().newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.getId())).execute();
// then
List<HistoricActivityInstance> historicInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstance.getId()).unfinished().orderByActivityId().asc().list();
Assert.assertEquals(2, historicInstances.size());
assertMigratedTo(historicInstances.get(0), targetDefinition, "newSubProcess");
assertMigratedTo(historicInstances.get(1), targetDefinition, "userTask");
assertEquals(processInstance.getId(), historicInstances.get(0).getParentActivityInstanceId());
assertEquals(historicInstances.get(0).getId(), historicInstances.get(1).getParentActivityInstanceId());
}
Aggregations