when(mockVariable.getProcessDefinitionKey()).thenReturn(processDefinitionKey); when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId); when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId); when(mockVariable.getExecutionId()).thenReturn(executionId); when(mockVariable.getErrorMessage()).thenReturn(errorMessage);
assertEquals("aVariable", historicVariable.getVariableName()); assertEquals("updated value", historicVariable.getValue()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId());
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 @OperateOnDeployment("clientDeployment") public void testVariableDeserializationOnProcessApplicationRestart() { // given ProcessInstance pi = runtimeService.startProcessInstanceByKey("testDeserializeVariable"); // when Assert.assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(pi.getId()).singleResult()); runtimeService.restartProcessInstances(pi.getProcessDefinitionId()) .startAfterActivity("servicetask1") .processInstanceIds(pi.getId()) .execute(); // then // Since the variable retrieval is done outside the Process Application Context as well, // custom object deserialization is disabled and a null check is performed List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery().disableCustomObjectDeserialization().list(); for (HistoricVariableInstance variable : variableInstances) { if (variable.getProcessInstanceId() != pi.getId() && variable instanceof HistoricVariableInstanceEntity) { Assert.assertNotNull(((HistoricVariableInstanceEntity) variable).getByteArrayValue()); } } } }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testHistoricVariableInstanceForSingleActivityInstantiation() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .startBeforeActivity("task1") .setVariable("aVar", "aValue") .execute(); ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId()); // then HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery() .variableName("aVar") .singleResult(); assertNotNull(historicVariable); assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName()); assertEquals("aValue", historicVariable.getValue()); HistoricDetail historicDetail = historyService.createHistoricDetailQuery() .variableInstanceId(historicVariable.getId()).singleResult(); assertEquals(instance.getId(), historicDetail.getProcessInstanceId()); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertNull(historicDetail.getActivityInstanceId()); assertTrue(historicDetail instanceof HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName()); assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue()); }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testHistoricVariableInstanceSetOnProcessInstance() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") // set the variables directly one the instance .setVariable("aVar", "aValue") .startBeforeActivity("task1") .execute(); ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId()); // then HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery() .variableName("aVar") .singleResult(); assertNotNull(historicVariable); assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName()); assertEquals("aValue", historicVariable.getValue()); HistoricDetail historicDetail = historyService.createHistoricDetailQuery() .variableInstanceId(historicVariable.getId()).singleResult(); assertEquals(instance.getId(), historicDetail.getProcessInstanceId()); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertEquals(instance.getId(), historicDetail.getActivityInstanceId()); assertTrue(historicDetail instanceof HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName()); assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue()); }
assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName());
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; }
assertEquals("aVariable", historicVariable.getVariableName()); assertEquals("updated value", historicVariable.getValue()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId()); assertEquals(processInstance.getId(), historicVariable.getProcessInstanceId());
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testHistoricVariableInstanceForSingleActivityInstantiation() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") .startBeforeActivity("task1") .setVariable("aVar", "aValue") .execute(); ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId()); // then HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery() .variableName("aVar") .singleResult(); assertNotNull(historicVariable); assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName()); assertEquals("aValue", historicVariable.getValue()); HistoricDetail historicDetail = historyService.createHistoricDetailQuery() .variableInstanceId(historicVariable.getId()).singleResult(); assertEquals(instance.getId(), historicDetail.getProcessInstanceId()); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertNull(historicDetail.getActivityInstanceId()); assertTrue(historicDetail instanceof HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName()); assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue()); }
@Deployment(resources = EXCLUSIVE_GATEWAY_PROCESS) public void testHistoricVariableInstanceSetOnProcessInstance() { // when ProcessInstance instance = runtimeService .createProcessInstanceByKey("exclusiveGateway") // set the variables directly one the instance .setVariable("aVar", "aValue") .startBeforeActivity("task1") .execute(); ActivityInstance activityInstance = runtimeService.getActivityInstance(instance.getId()); // then HistoricVariableInstance historicVariable = historyService.createHistoricVariableInstanceQuery() .variableName("aVar") .singleResult(); assertNotNull(historicVariable); assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName()); assertEquals("aValue", historicVariable.getValue()); HistoricDetail historicDetail = historyService.createHistoricDetailQuery() .variableInstanceId(historicVariable.getId()).singleResult(); assertEquals(instance.getId(), historicDetail.getProcessInstanceId()); assertNotNull(historicDetail); // TODO: fix if this is not ok due to CAM-3886 assertEquals(instance.getId(), historicDetail.getActivityInstanceId()); assertTrue(historicDetail instanceof HistoricVariableUpdate); assertEquals("aVar", ((HistoricVariableUpdate) historicDetail).getVariableName()); assertEquals("aValue", ((HistoricVariableUpdate) historicDetail).getValue()); }
assertEquals(instance.getId(), historicVariable.getProcessInstanceId()); assertEquals(activityInstance.getId(), historicVariable.getActivityInstanceId()); assertEquals("aVar", historicVariable.getName());