public virtual void testHistoricVariableInstanceSetOnProcessInstance() { // when ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").setVariable("aVar", "aValue").startBeforeActivity("task1").execute(); ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.Id); // then HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult(); assertNotNull(historicVariable); assertEquals(instance.Id, historicVariable.ProcessInstanceId); assertEquals(activityInstance.Id, historicVariable.ActivityInstanceId); assertEquals("aVar", historicVariable.Name); assertEquals("aValue", historicVariable.Value); HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.Id).singleResult(); assertEquals(instance.Id, historicDetail.ProcessInstanceId); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertEquals(instance.Id, historicDetail.ActivityInstanceId); assertTrue(historicDetail is HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate)historicDetail).VariableName); assertEquals("aValue", ((HistoricVariableUpdate)historicDetail).Value); }
public virtual void testMigrateEventScopeVariable() { //given ProcessDefinition sourceDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); ProcessDefinition targetDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapActivities("userTask2", "userTask2").mapActivities("subProcess", "subProcess").mapActivities("compensationBoundary", "compensationBoundary").build(); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceDefinition.Id); Execution subProcessExecution = runtimeService.createExecutionQuery().activityId("userTask1").singleResult(); runtimeService.setVariableLocal(subProcessExecution.Id, "foo", "bar"); testHelper.completeTask("userTask1"); Execution eventScopeExecution = runtimeService.createExecutionQuery().activityId("subProcess").singleResult(); HistoricVariableInstance eventScopeVariable = historyService.createHistoricVariableInstanceQuery().executionIdIn(eventScopeExecution.Id).singleResult(); //when runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.Id).execute(); // then HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableId(eventScopeVariable.Id).singleResult(); Assert.assertEquals(targetDefinition.Id, historicVariableInstance.ProcessDefinitionId); }
public virtual void testScriptResourceListener() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); assertTrue((bool?)runtimeService.getVariable(processInstance.Id, "create")); taskService.setAssignee(task.Id, "test"); assertTrue((bool?)runtimeService.getVariable(processInstance.Id, "assignment")); taskService.complete(task.Id); assertTrue((bool?)runtimeService.getVariable(processInstance.Id, "complete")); task = taskService.createTaskQuery().singleResult(); assertNotNull(task); runtimeService.deleteProcessInstance(processInstance.Id, "test"); if (processEngineConfiguration.HistoryLevel.Id >= HISTORYLEVEL_AUDIT) { HistoricVariableInstance variable = historyService.createHistoricVariableInstanceQuery().variableName("delete").singleResult(); assertNotNull(variable); assertTrue((bool?)variable.Value); } }
public virtual void testStartBeforeScopeWithVariablesInHistory() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("subprocess"); runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("innerTask").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.Id); HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult(); assertNotNull(procInstVariable); assertEquals(updatedTree.Id, procInstVariable.ActivityInstanceId); assertEquals("procInstVar", procInstVariable.Name); assertEquals("procInstValue", procInstVariable.Value); HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.Id).singleResult(); assertNotNull(procInstanceVarDetail); // when starting before/after an activity instance, the activity instance id of the // execution is null and so is the activity instance id of the historic detail assertNull(procInstanceVarDetail.ActivityInstanceId); HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult(); assertNotNull(localVariable); assertEquals(updatedTree.getActivityInstances("subProcess")[0].Id, localVariable.ActivityInstanceId); assertEquals("localVar", localVariable.Name); assertEquals("localValue", localVariable.Value); HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.Id).singleResult(); assertNotNull(localInstanceVarDetail); assertNull(localInstanceVarDetail.ActivityInstanceId); }
protected internal virtual void verifyRemoveVariable() { verifyVariableInstanceCount(0); assertNull(runtimeService.createVariableInstanceQuery().singleResult()); HistoricVariableInstance deletedVariable = historyService.createHistoricVariableInstanceQuery().includeDeleted().singleResult(); Assert.assertEquals("DELETED", deletedVariable.State); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUpRuntimeData() public virtual void setUpRuntimeData() { mockInstanceBuilder = MockProvider.mockHistoricVariableInstance(); mockInstance = mockInstanceBuilder.build(); IList <HistoricVariableInstance> mocks = new List <HistoricVariableInstance>(); mocks.Add(mockInstance); mockedQuery = setUpMockHistoricVariableInstanceQuery(mocks); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception public virtual void execute(DelegateExecution execution) { HistoryService historyService = execution.ProcessEngineServices.HistoryService; HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult(); IList <string> list = (IList <string>)variableInstance.Value; // implicit update of the list, should not trigger an update // of the value since we deal with historic variables list.Add(NEW_ELEMENT); }
private void createHistoricVariableInstanceMock() { IList <HistoricVariableInstance> variables = new List <HistoricVariableInstance>(); HistoricVariableInstance mockInstance = MockProvider.createMockHistoricVariableInstance(); variables.Add(mockInstance); HistoricVariableInstanceQuery mockHistoricVariableInstanceQuery = mock(typeof(HistoricVariableInstanceQuery)); when(mockHistoricVariableInstanceQuery.list()).thenReturn(variables); when(mockHistoryService.createHistoricVariableInstanceQuery()).thenReturn(mockHistoricVariableInstanceQuery); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void execute(org.camunda.bpm.engine.delegate.DelegateExecution execution) throws Exception public virtual void execute(DelegateExecution execution) { HistoryService historyService = execution.ProcessEngineServices.HistoryService; HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult(); HistoricVariableUpdate initialUpdate = (HistoricVariableUpdate)historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variableInstance.Id).orderPartiallyByOccurrence().asc().list().get(0); IList <string> list = (IList <string>)initialUpdate.Value; // implicit update of the list, should not trigger an update // of the value since we deal with historic variables list.Add(NEW_ELEMENT); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testSetVariableOnServiceTaskInsideParallelBranch() public virtual void testSetVariableOnServiceTaskInsideParallelBranch() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.Id, variable.ActivityInstanceId); assertProcessEnded(pi.Id); }
public virtual HistoricVariableInstance build() { HistoricVariableInstance mockVariable = mock(typeof(HistoricVariableInstance)); when(mockVariable.Id).thenReturn(id_Renamed); when(mockVariable.Name).thenReturn(name_Renamed); when(mockVariable.VariableName).thenReturn(name_Renamed); when(mockVariable.TypeName).thenReturn(value.Type.Name); when(mockVariable.VariableTypeName).thenReturn(value.Type.Name); if (value.GetType().IsAssignableFrom(typeof(ObjectValue))) { ObjectValue objectValue = (ObjectValue)value; if (objectValue.Deserialized) { when(mockVariable.Value).thenReturn(value.Value); } else { when(mockVariable.Value).thenReturn(null); } } else { when(mockVariable.Value).thenReturn(value.Value); } when(mockVariable.TypedValue).thenReturn(value); when(mockVariable.ProcessDefinitionKey).thenReturn(processDefinitionKey_Renamed); when(mockVariable.ProcessDefinitionId).thenReturn(processDefinitionId_Renamed); when(mockVariable.ProcessInstanceId).thenReturn(processInstanceId_Renamed); when(mockVariable.ExecutionId).thenReturn(executionId_Renamed); when(mockVariable.ErrorMessage).thenReturn(errorMessage_Renamed); when(mockVariable.ActivtyInstanceId).thenReturn(activityInstanceId_Renamed); when(mockVariable.ActivityInstanceId).thenReturn(activityInstanceId_Renamed); when(mockVariable.CaseDefinitionKey).thenReturn(caseDefinitionKey_Renamed); when(mockVariable.CaseDefinitionId).thenReturn(caseDefinitionId_Renamed); when(mockVariable.CaseInstanceId).thenReturn(caseInstanceId_Renamed); when(mockVariable.CaseExecutionId).thenReturn(caseExecutionId_Renamed); when(mockVariable.TaskId).thenReturn(taskId_Renamed); when(mockVariable.TenantId).thenReturn(tenantId_Renamed); when(mockVariable.CreateTime).thenReturn(createTime_Renamed); when(mockVariable.RemovalTime).thenReturn(removalTime_Renamed); when(mockVariable.RootProcessInstanceId).thenReturn(rootProcessInstanceId_Renamed); return(mockVariable); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testInputMappings() public virtual void testInputMappings() { // given string processInstanceId = runtimeService.startProcessInstanceByKey("process").Id; HistoricActivityInstanceQuery activityInstanceQuery = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId); string theService1Id = activityInstanceQuery.activityId("theService1").singleResult().Id; string theService2Id = activityInstanceQuery.activityId("theService2").singleResult().Id; string theTaskId = activityInstanceQuery.activityId("theTask").singleResult().Id; // when (1) HistoricVariableInstance firstVariable = historyService.createHistoricVariableInstanceQuery().variableName("firstInputVariable").singleResult(); // then (1) assertEquals(theService1Id, firstVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail firstVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(firstVariable.Id).singleResult(); assertEquals(theService1Id, firstVariableDetail.ActivityInstanceId); } // when (2) HistoricVariableInstance secondVariable = historyService.createHistoricVariableInstanceQuery().variableName("secondInputVariable").singleResult(); // then (2) assertEquals(theService2Id, secondVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail secondVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(secondVariable.Id).singleResult(); assertEquals(theService2Id, secondVariableDetail.ActivityInstanceId); } // when (3) HistoricVariableInstance thirdVariable = historyService.createHistoricVariableInstanceQuery().variableName("thirdInputVariable").singleResult(); // then (3) assertEquals(theTaskId, thirdVariable.ActivityInstanceId); if (processEngineConfiguration.HistoryLevel.Id > ProcessEngineConfigurationImpl.HISTORYLEVEL_AUDIT) { HistoricDetail thirdVariableDetail = historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(thirdVariable.Id).singleResult(); assertEquals(theTaskId, thirdVariableDetail.ActivityInstanceId); } }
public virtual void testStartBeforeAsyncWithVariablesInHistory() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); runtimeService.createProcessInstanceModification(processInstance.Id).startBeforeActivity("task2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.Id); HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult(); assertNotNull(procInstVariable); assertEquals(updatedTree.Id, procInstVariable.ActivityInstanceId); assertEquals("procInstVar", procInstVariable.Name); assertEquals("procInstValue", procInstVariable.Value); HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.Id).singleResult(); assertNotNull(procInstanceVarDetail); // when starting before/after an activity instance, the activity instance id of the // execution is null and so is the activity instance id of the historic detail assertNull(procInstanceVarDetail.ActivityInstanceId); HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult(); assertNotNull(localVariable); // the following is null because localVariable is local on a concurrent execution // but the concurrent execution does not execute an activity at the time the variable is set assertNull(localVariable.ActivityInstanceId); assertEquals("localVar", localVariable.Name); assertEquals("localValue", localVariable.Value); HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.Id).singleResult(); assertNotNull(localInstanceVarDetail); assertNull(localInstanceVarDetail.ActivityInstanceId); // end process instance completeTasksInOrder("task1"); Job job = managementService.createJobQuery().singleResult(); managementService.executeJob(job.Id); completeTasksInOrder("task2"); assertProcessEnded(processInstance.Id); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testSetVariableLocalOnServiceTaskInsideSubProcess() public virtual void testSetVariableLocalOnServiceTaskInsideSubProcess() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("process"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); string activityInstanceId = historyService.createHistoricActivityInstanceQuery().activityId("SubProcess_1").singleResult().Id; HistoricVariableInstance variable = query.singleResult(); // the variable is in the sub process scope assertEquals(activityInstanceId, variable.ActivityInstanceId); assertProcessEnded(pi.Id); }
/// <summary> /// Tests that an implicit object value update happens in the context of the /// process application. /// </summary> //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testExecutionVariableImplicitObjectValueUpdate() throws com.fasterxml.jackson.core.JsonProcessingException, java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testExecutionVariableImplicitObjectValueUpdate() { // given a process instance and a task ProcessInstance pi = runtimeService.startProcessInstanceByKey("implicitProcessVariableUpdate"); // when setting a variable such that the process-application-local dataformat applies DateTime date = new DateTime(JsonSerializable.ONE_DAY_IN_MILLIS * 10); // 10th of January 1970 JsonSerializable jsonSerializable = new JsonSerializable(date); try { ProcessApplicationContext.CurrentProcessApplication = ReferenceStoringProcessApplication.INSTANCE; runtimeService.setVariable(pi.Id, ImplicitObjectValueUpdateHandler.VARIABLE_NAME, Variables.objectValue(jsonSerializable).serializationDataFormat(Variables.SerializationDataFormats.JSON).create()); } finally { ProcessApplicationContext.clear(); } // and triggering an implicit update of the object value variable Task task = taskService.createTaskQuery().processInstanceId(pi.Id).singleResult(); taskService.complete(task.Id); // then the process-application-local format was used for making the update ObjectValue objectValue = runtimeService.getVariableTyped(pi.Id, ImplicitObjectValueUpdateHandler.VARIABLE_NAME, false); ImplicitObjectValueUpdateHandler.addADay(jsonSerializable); string serializedValue = objectValue.ValueSerialized; string expectedSerializedValue = jsonSerializable.toExpectedJsonString(JsonDataFormatConfigurator.DATE_FORMAT); ObjectMapper objectMapper = new ObjectMapper(); JsonNode actualJsonTree = objectMapper.readTree(serializedValue); JsonNode expectedJsonTree = objectMapper.readTree(expectedSerializedValue); // JsonNode#equals makes a deep comparison Assert.assertEquals(expectedJsonTree, actualJsonTree); // and it is also correct in the history HistoricVariableInstance historicObjectValue = historyService.createHistoricVariableInstanceQuery().processInstanceId(pi.Id).variableName(ImplicitObjectValueUpdateHandler.VARIABLE_NAME).disableCustomObjectDeserialization().singleResult(); serializedValue = ((ObjectValue)historicObjectValue.TypedValue).ValueSerialized; actualJsonTree = objectMapper.readTree(serializedValue); Assert.assertEquals(expectedJsonTree, actualJsonTree); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Ignore @Test public void testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile() public virtual void testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile() { HistoricVariableInstanceQuery query = mock(typeof(HistoricVariableInstanceQuery)); HistoricVariableInstance instance = mock(typeof(HistoricVariableInstance)); string filename = "test.txt"; sbyte[] byteContent = "test".GetBytes(); string encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.ToString()).encoding(encoding).create(); when(instance.TypedValue).thenReturn(variableValue); when(query.singleResult()).thenReturn(instance); when(mockHistoryService.createHistoricVariableInstanceQuery()).thenReturn(query); given().pathParam("name", EXAMPLE_ENGINE_NAME).pathParam("id", MockProvider.EXAMPLE_PROCESS_DEFINITION_ID).then().expect().statusCode(Status.OK.StatusCode).body(@is(equalTo(StringHelper.NewString(byteContent)))).and().header("Content-Disposition", "attachment; filename=" + filename).contentType(CoreMatchers.either <string>(equalTo(ContentType.TEXT.ToString() + ";charset=UTF-8")).or(equalTo(ContentType.TEXT.ToString() + " ;charset=UTF-8"))).when().get(HISTORY_BINARY_VARIABLE_INSTANCE_URL); verify(mockHistoryService).createHistoricVariableInstanceQuery(); verifyZeroInteractions(processEngine); }
public virtual void testHistoricProcessInstanceAsyncStartEvent() { // when ProcessInstance instance = runtimeService.createProcessInstanceByKey("exclusiveGateway").startBeforeActivity("task2").setVariable("aVar", "aValue").execute(); // then HistoricProcessInstance historicInstance = historyService.createHistoricProcessInstanceQuery().singleResult(); assertNotNull(historicInstance); assertEquals(instance.Id, historicInstance.Id); assertNotNull(historicInstance.StartTime); assertNull(historicInstance.EndTime); // should be the first activity started assertEquals("task2", historicInstance.StartActivityId); // task2 wasn't entered yet assertEquals(0, historyService.createHistoricActivityInstanceQuery().count()); // history events for variables exist already ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.Id); HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery().variableName("aVar").singleResult(); assertNotNull(historicVariable); assertEquals(instance.Id, historicVariable.ProcessInstanceId); assertEquals(activityInstance.Id, historicVariable.ActivityInstanceId); assertEquals("aVar", historicVariable.Name); assertEquals("aValue", historicVariable.Value); HistoricDetail historicDetail = historyService.createHistoricDetailQuery().variableInstanceId(historicVariable.Id).singleResult(); assertEquals(instance.Id, historicDetail.ProcessInstanceId); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertNull(historicDetail.ActivityInstanceId); assertTrue(historicDetail is HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate)historicDetail).VariableName); assertEquals("aValue", ((HistoricVariableUpdate)historicDetail).Value); }
public virtual void testSetVariableOnUserTaskInsideSubProcess() { ProcessInstance pi = runtimeService.startProcessInstanceByKey("startSimpleSubProcess"); Task task = taskService.createTaskQuery().singleResult(); assertNotNull(task); taskService.setVariable(task.Id, "testVar", "testValue"); HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery(); assertEquals(1, query.count()); HistoricVariableInstance variable = query.singleResult(); // the variable is in the process instance scope assertEquals(pi.Id, variable.ActivityInstanceId); taskService.complete(task.Id); assertProcessEnded(pi.Id); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testMessageCorrelationWithTransientVariable() public virtual void testMessageCorrelationWithTransientVariable() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().message("message").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', blob);").endEvent().done(); testRule.deploy(instance); runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", false))); // when VariableMap correlationKeys = Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", true)); VariableMap variables = Variables.createVariables().putValueTyped("blob", Variables.stringValue("blob", true)); runtimeService.correlateMessage("message", correlationKeys, variables); // then VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult(); assertNull(variableInstance); HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableName("abc").singleResult(); assertNotNull(historicVariableInstance); assertEquals("blob", historicVariableInstance.Value); }
public virtual void testStartTransitionWithVariablesInHistory() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("exclusiveGateway"); runtimeService.createProcessInstanceModification(processInstance.Id).startTransition("flow2").setVariable("procInstVar", "procInstValue").setVariableLocal("localVar", "localValue").execute(); ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstance.Id); HistoricVariableInstance procInstVariable = historyService.createHistoricVariableInstanceQuery().variableName("procInstVar").singleResult(); assertNotNull(procInstVariable); assertEquals(updatedTree.Id, procInstVariable.ActivityInstanceId); assertEquals("procInstVar", procInstVariable.Name); assertEquals("procInstValue", procInstVariable.Value); HistoricDetail procInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(procInstVariable.Id).singleResult(); assertNotNull(procInstanceVarDetail); assertEquals(updatedTree.Id, procInstVariable.ActivityInstanceId); HistoricVariableInstance localVariable = historyService.createHistoricVariableInstanceQuery().variableName("localVar").singleResult(); assertNotNull(localVariable); assertEquals(updatedTree.Id, procInstVariable.ActivityInstanceId); assertEquals("localVar", localVariable.Name); assertEquals("localValue", localVariable.Value); HistoricDetail localInstanceVarDetail = historyService.createHistoricDetailQuery().variableInstanceId(localVariable.Id).singleResult(); assertNotNull(localInstanceVarDetail); // when starting before/after an activity instance, the activity instance id of the // execution is null and so is the activity instance id of the historic detail assertNull(localInstanceVarDetail.ActivityInstanceId); completeTasksInOrder("task1", "task1"); assertProcessEnded(processInstance.Id); }
public virtual 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.Id); runtimeService.setVariable(processInstance.Id, "test", 3537); HistoricVariableInstance instance = historyService.createHistoricVariableInstanceQuery().singleResult(); MigrationPlan migrationPlan = rule.RuntimeService.createMigrationPlan(sourceDefinition.Id, targetDefinition.Id).mapActivities("userTask", "userTask").build(); //when runtimeService.newMigration(migrationPlan).processInstanceIds(Arrays.asList(processInstance.Id)).execute(); //then HistoricVariableInstance migratedInstance = historyService.createHistoricVariableInstanceQuery().singleResult(); assertEquals(targetDefinition.Key, migratedInstance.ProcessDefinitionKey); assertEquals(targetDefinition.Id, migratedInstance.ProcessDefinitionId); assertEquals(instance.ActivityInstanceId, migratedInstance.ActivityInstanceId); assertEquals(instance.ExecutionId, migratedInstance.ExecutionId); }