Search in sources :

Example 46 with RequiredHistoryLevel

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);
}
Also used : ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 47 with RequiredHistoryLevel

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());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 48 with RequiredHistoryLevel

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());
}
Also used : Batch(org.camunda.bpm.engine.batch.Batch) UserOperationLogQuery(org.camunda.bpm.engine.history.UserOperationLogQuery) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 49 with RequiredHistoryLevel

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());
}
Also used : HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) LockedExternalTask(org.camunda.bpm.engine.externaltask.LockedExternalTask) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) Incident(org.camunda.bpm.engine.runtime.Incident) Test(org.junit.Test) Deployment(org.camunda.bpm.engine.test.Deployment) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Example 50 with RequiredHistoryLevel

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());
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance) Test(org.junit.Test) RequiredHistoryLevel(org.camunda.bpm.engine.test.RequiredHistoryLevel)

Aggregations

RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)76 Test (org.junit.Test)47 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)43 Deployment (org.camunda.bpm.engine.test.Deployment)24 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)17 Batch (org.camunda.bpm.engine.batch.Batch)13 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)13 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)12 Task (org.camunda.bpm.engine.task.Task)12 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)12 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)11 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)10 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)8 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)7 Calendar (java.util.Calendar)6 HistoricTaskInstance (org.camunda.bpm.engine.history.HistoricTaskInstance)6 Job (org.camunda.bpm.engine.runtime.Job)6 VariableInstanceQuery (org.camunda.bpm.engine.runtime.VariableInstanceQuery)6 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)5 GregorianCalendar (java.util.GregorianCalendar)4