public virtual void testRestartProcessInstanceSyncWithTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.ProcessDefinitionId); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_ONE)); // when runtimeService.restartProcessInstances(processInstance.ProcessDefinitionId).startBeforeActivity("userTask").historicProcessInstanceQuery(query).execute(); // then ProcessInstance restartedInstance = runtimeService.createProcessInstanceQuery().active().processDefinitionId(processInstance.ProcessDefinitionId).singleResult(); assertNotNull(restartedInstance); assertEquals(restartedInstance.TenantId, TENANT_ONE); }
public virtual void testFailToRestartProcessInstanceAsyncWithOtherTenantIdByHistoricProcessInstanceQuery() { // given ProcessInstance processInstance = startAndDeleteProcessInstance(TENANT_ONE, PROCESS); HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionId(processInstance.ProcessDefinitionId); identityService.setAuthentication("user", null, Collections.singletonList(TENANT_TWO)); try { // when runtimeService.restartProcessInstances(processInstance.ProcessDefinitionId).startBeforeActivity("userTask").historicProcessInstanceQuery(query).executeAsync(); } catch (ProcessEngineException e) { assertThat(e.Message, containsString("processInstanceIds is empty")); } }
public virtual void testMigrateHistoryProcessInstance() { //given HistoricProcessInstanceQuery sourceHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id); HistoricProcessInstanceQuery targetHistoryProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery().processDefinitionId(targetProcessDefinition.Id); //when assertEquals(1, sourceHistoryProcessInstanceQuery.count()); assertEquals(0, targetHistoryProcessInstanceQuery.count()); ProcessInstanceQuery sourceProcessInstanceQuery = runtimeService.createProcessInstanceQuery().processDefinitionId(sourceProcessDefinition.Id); runtimeService.newMigration(migrationPlan).processInstanceQuery(sourceProcessInstanceQuery).execute(); //then assertEquals(0, sourceHistoryProcessInstanceQuery.count()); assertEquals(1, targetHistoryProcessInstanceQuery.count()); HistoricProcessInstance instance = targetHistoryProcessInstanceQuery.singleResult(); assertEquals(instance.ProcessDefinitionKey, targetProcessDefinition.Key); }