when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId); when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId); when(mockVariable.getExecutionId()).thenReturn(executionId); when(mockVariable.getErrorMessage()).thenReturn(errorMessage); when(mockVariable.getActivtyInstanceId()).thenReturn(activityInstanceId);
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testHistoricVariableInstanceQueryByExecutionIds() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("myVar", "test123"); ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId()); assertEquals(2, query.count()); List<HistoricVariableInstance> variableInstances = query.list(); assertEquals(2, variableInstances.size()); for (HistoricVariableInstance variableInstance : variableInstances) { assertEquals(processInstance1.getId(), variableInstance.getExecutionId()); } Map<String, Object> variables2 = new HashMap<String, Object>(); variables2.put("myVar", "test123"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2); query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId(), processInstance2.getId()); assertEquals(3, query.list().size()); assertEquals(3, query.count()); }
public static HistoricVariableInstanceDto fromHistoricVariableInstance(HistoricVariableInstance historicVariableInstance) { HistoricVariableInstanceDto dto = new HistoricVariableInstanceDto(); dto.id = historicVariableInstance.getId(); dto.name = historicVariableInstance.getName(); dto.processDefinitionKey = historicVariableInstance.getProcessDefinitionKey(); dto.processDefinitionId = historicVariableInstance.getProcessDefinitionId(); dto.processInstanceId = historicVariableInstance.getProcessInstanceId(); dto.executionId = historicVariableInstance.getExecutionId(); dto.activityInstanceId = historicVariableInstance.getActivityInstanceId(); dto.caseDefinitionKey = historicVariableInstance.getCaseDefinitionKey(); dto.caseDefinitionId = historicVariableInstance.getCaseDefinitionId(); dto.caseInstanceId = historicVariableInstance.getCaseInstanceId(); dto.caseExecutionId = historicVariableInstance.getCaseExecutionId(); dto.taskId = historicVariableInstance.getTaskId(); dto.tenantId = historicVariableInstance.getTenantId(); dto.state = historicVariableInstance.getState(); dto.createTime = historicVariableInstance.getCreateTime(); dto.removalTime = historicVariableInstance.getRemovalTime(); dto.rootProcessInstanceId = historicVariableInstance.getRootProcessInstanceId(); if(historicVariableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, historicVariableInstance.getTypedValue()); } else { dto.errorMessage = historicVariableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(historicVariableInstance.getTypeName()); } return dto; }
public static HistoricVariableInstanceDto fromHistoricVariableInstance(HistoricVariableInstance historicVariableInstance) { HistoricVariableInstanceDto dto = new HistoricVariableInstanceDto(); dto.id = historicVariableInstance.getId(); dto.name = historicVariableInstance.getName(); dto.processDefinitionKey = historicVariableInstance.getProcessDefinitionKey(); dto.processDefinitionId = historicVariableInstance.getProcessDefinitionId(); dto.processInstanceId = historicVariableInstance.getProcessInstanceId(); dto.executionId = historicVariableInstance.getExecutionId(); dto.activityInstanceId = historicVariableInstance.getActivityInstanceId(); dto.caseDefinitionKey = historicVariableInstance.getCaseDefinitionKey(); dto.caseDefinitionId = historicVariableInstance.getCaseDefinitionId(); dto.caseInstanceId = historicVariableInstance.getCaseInstanceId(); dto.caseExecutionId = historicVariableInstance.getCaseExecutionId(); dto.taskId = historicVariableInstance.getTaskId(); dto.tenantId = historicVariableInstance.getTenantId(); dto.state = historicVariableInstance.getState(); dto.createTime = historicVariableInstance.getCreateTime(); dto.removalTime = historicVariableInstance.getRemovalTime(); dto.rootProcessInstanceId = historicVariableInstance.getRootProcessInstanceId(); if(historicVariableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, historicVariableInstance.getTypedValue()); } else { dto.errorMessage = historicVariableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(historicVariableInstance.getTypeName()); } return dto; }
@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()); }
@Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testHistoricVariableInstanceQueryByExecutionIds() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("myVar", "test123"); ProcessInstance processInstance1 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId()); assertEquals(2, query.count()); List<HistoricVariableInstance> variableInstances = query.list(); assertEquals(2, variableInstances.size()); for (HistoricVariableInstance variableInstance : variableInstances) { assertEquals(processInstance1.getId(), variableInstance.getExecutionId()); } Map<String, Object> variables2 = new HashMap<String, Object>(); variables2.put("myVar", "test123"); ProcessInstance processInstance2 = runtimeService.startProcessInstanceByKey("oneTaskProcess", variables2); query = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance1.getId(), processInstance2.getId()); assertEquals(3, query.list().size()); assertEquals(3, query.count()); }
public static HistoricVariableInstanceDto fromHistoricVariableInstance(HistoricVariableInstance historicVariableInstance) { HistoricVariableInstanceDto dto = new HistoricVariableInstanceDto(); dto.id = historicVariableInstance.getId(); dto.name = historicVariableInstance.getName(); dto.processDefinitionKey = historicVariableInstance.getProcessDefinitionKey(); dto.processDefinitionId = historicVariableInstance.getProcessDefinitionId(); dto.processInstanceId = historicVariableInstance.getProcessInstanceId(); dto.executionId = historicVariableInstance.getExecutionId(); dto.activityInstanceId = historicVariableInstance.getActivityInstanceId(); dto.caseDefinitionKey = historicVariableInstance.getCaseDefinitionKey(); dto.caseDefinitionId = historicVariableInstance.getCaseDefinitionId(); dto.caseInstanceId = historicVariableInstance.getCaseInstanceId(); dto.caseExecutionId = historicVariableInstance.getCaseExecutionId(); dto.taskId = historicVariableInstance.getTaskId(); dto.tenantId = historicVariableInstance.getTenantId(); dto.state = historicVariableInstance.getState(); dto.createTime = historicVariableInstance.getCreateTime(); dto.removalTime = historicVariableInstance.getRemovalTime(); dto.rootProcessInstanceId = historicVariableInstance.getRootProcessInstanceId(); if(historicVariableInstance.getErrorMessage() == null) { VariableValueDto.fromTypedValue(dto, historicVariableInstance.getTypedValue()); } else { dto.errorMessage = historicVariableInstance.getErrorMessage(); dto.type = VariableValueDto.toRestApiTypeName(historicVariableInstance.getTypeName()); } return dto; }
@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()); }