when(mockVariable.getId()).thenReturn(id); when(mockVariable.getVariableName()).thenReturn(name); when(mockVariable.getVariableInstanceId()).thenReturn(variableInstanceId); when(mockVariable.getVariableTypeName()).thenReturn(typedValue.getType().getName());
protected static void fromHistoricVariableUpdate(HistoricVariableUpdateDto dto, HistoricVariableUpdate historicVariableUpdate) { dto.revision = historicVariableUpdate.getRevision(); dto.variableName = historicVariableUpdate.getVariableName(); dto.variableInstanceId = historicVariableUpdate.getVariableInstanceId(); if (historicVariableUpdate.getErrorMessage() == null) { try { VariableValueDto variableValueDto = VariableValueDto.fromTypedValue(historicVariableUpdate.getTypedValue()); dto.value = variableValueDto.getValue(); dto.variableType = variableValueDto.getType(); dto.valueInfo = variableValueDto.getValueInfo(); } catch (RuntimeException e) { dto.errorMessage = e.getMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } } else { dto.errorMessage = historicVariableUpdate.getErrorMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } }
protected static void fromHistoricVariableUpdate(HistoricVariableUpdateDto dto, HistoricVariableUpdate historicVariableUpdate) { dto.revision = historicVariableUpdate.getRevision(); dto.variableName = historicVariableUpdate.getVariableName(); dto.variableInstanceId = historicVariableUpdate.getVariableInstanceId(); if (historicVariableUpdate.getErrorMessage() == null) { try { VariableValueDto variableValueDto = VariableValueDto.fromTypedValue(historicVariableUpdate.getTypedValue()); dto.value = variableValueDto.getValue(); dto.variableType = variableValueDto.getType(); dto.valueInfo = variableValueDto.getValueInfo(); } catch (RuntimeException e) { dto.errorMessage = e.getMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } } else { dto.errorMessage = historicVariableUpdate.getErrorMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } }
@Test public void testVariableInstance() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "someName"; String variableValue = "someValue"; taskService.setVariable(newTask.getId(), variableName, variableValue); VariableInstance variable = runtimeService .createVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableUpdate result = (HistoricVariableUpdate) historyService .createHistoricDetailQuery() .variableUpdates() .singleResult(); assertNotNull(result); assertEquals(variable.getId(), result.getVariableInstanceId()); taskService.deleteTask(newTask.getId(), true); }
protected static void fromHistoricVariableUpdate(HistoricVariableUpdateDto dto, HistoricVariableUpdate historicVariableUpdate) { dto.revision = historicVariableUpdate.getRevision(); dto.variableName = historicVariableUpdate.getVariableName(); dto.variableInstanceId = historicVariableUpdate.getVariableInstanceId(); if (historicVariableUpdate.getErrorMessage() == null) { try { VariableValueDto variableValueDto = VariableValueDto.fromTypedValue(historicVariableUpdate.getTypedValue()); dto.value = variableValueDto.getValue(); dto.variableType = variableValueDto.getType(); dto.valueInfo = variableValueDto.getValueInfo(); } catch (RuntimeException e) { dto.errorMessage = e.getMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } } else { dto.errorMessage = historicVariableUpdate.getErrorMessage(); dto.variableType = VariableValueDto.toRestApiTypeName(historicVariableUpdate.getTypeName()); } }
@Test public void testVariableInstance() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "someName"; String variableValue = "someValue"; taskService.setVariable(newTask.getId(), variableName, variableValue); VariableInstance variable = runtimeService .createVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableUpdate result = (HistoricVariableUpdate) historyService .createHistoricDetailQuery() .variableUpdates() .singleResult(); assertNotNull(result); assertEquals(variable.getId(), result.getVariableInstanceId()); taskService.deleteTask(newTask.getId(), true); }