@Override protected TypedValue transformQueryResultIntoTypedValue(HistoricVariableInstance queryResult) { return queryResult.getTypedValue(); }
@Override protected TypedValue transformQueryResultIntoTypedValue(HistoricVariableInstance queryResult) { return queryResult.getTypedValue(); }
when(mockVariable.getTypedValue()).thenReturn(value); when(mockVariable.getProcessDefinitionKey()).thenReturn(processDefinitionKey); when(mockVariable.getProcessDefinitionId()).thenReturn(processDefinitionId);
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) { HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService(); List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery() .executionIdIn(processInstance.getId()) .list(); VariableMap variables = new VariableMapImpl(); for (HistoricVariableInstance variable : historicVariables) { variables.putValueTyped(variable.getName(), variable.getTypedValue()); } return variables; }
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) { HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService(); List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery() .executionIdIn(processInstance.getId()) .list(); VariableMap variables = new VariableMapImpl(); for (HistoricVariableInstance variable : historicVariables) { variables.putValueTyped(variable.getName(), variable.getTypedValue()); } return variables; }
private void checkVariables(VariableMap map, int expectedSize) { List<HistoricVariableInstance> variables = engineRule.getHistoryService() .createHistoricVariableInstanceQuery() .orderByVariableName() .asc() .list(); assertEquals(expectedSize, variables.size()); assertEquals(variables.size(), map.size()); for (HistoricVariableInstance instance : variables) { assertTrue(map.containsKey(instance.getName())); Object instanceValue = instance.getTypedValue().getValue(); Object mapValue = map.getValueTyped(instance.getName()).getValue(); if (instanceValue == null) { assertNull(mapValue); } else if (instanceValue instanceof byte[]) { assertTrue(Arrays.equals((byte[]) instanceValue, (byte[]) mapValue)); } else { assertEquals(instanceValue, mapValue); } } }
@Override protected TypedValue transformQueryResultIntoTypedValue(HistoricVariableInstance queryResult) { return queryResult.getTypedValue(); }
@Ignore @Test public void testHistoryServiceEngineAccess_HistoricVariableInstanceBinaryFile() { HistoricVariableInstanceQuery query = mock(HistoricVariableInstanceQuery.class); HistoricVariableInstance instance = mock(HistoricVariableInstance.class); String filename = "test.txt"; byte[] byteContent = "test".getBytes(); String encoding = "UTF-8"; FileValue variableValue = Variables.fileValue(filename).file(byteContent).mimeType(ContentType.TEXT.toString()).encoding(encoding).create(); when(instance.getTypedValue()).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.getStatusCode()) . body(is(equalTo(new String(byteContent)))) .and() .header("Content-Disposition", "attachment; filename="+filename) .contentType(CoreMatchers.<String>either(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 void testDisableCustomObjectDeserialization() { // given Task newTask = taskService.newTask(); taskService.saveTask(newTask); Map<String, Object> variables = new HashMap<String, Object>(); variables.put("customSerializable", new CustomSerializable()); variables.put("failingSerializable", new FailingSerializable()); taskService.setVariables(newTask.getId(), variables); // when List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery() .disableCustomObjectDeserialization() .list(); // then assertEquals(2, variableInstances.size()); for (HistoricVariableInstance variableInstance : variableInstances) { assertNull(variableInstance.getErrorMessage()); ObjectValue typedValue = (ObjectValue) variableInstance.getTypedValue(); assertNotNull(typedValue); assertFalse(typedValue.isDeserialized()); // cannot access the deserialized value try { typedValue.getValue(); } catch(IllegalStateException e) { assertTextPresent("Object is not deserialized", e.getMessage()); } assertNotNull(typedValue.getValueSerialized()); } taskService.deleteTask(newTask.getId(), true); }
assertNull(variableInstance.getErrorMessage()); ObjectValue typedValue = (ObjectValue) variableInstance.getTypedValue(); assertNotNull(typedValue); assertFalse(typedValue.isDeserialized());
.singleResult(); serializedValue = ((ObjectValue) historicObjectValue.getTypedValue()).getValueSerialized(); actualJsonTree = objectMapper.readTree(serializedValue); Assert.assertEquals(expectedJsonTree, actualJsonTree);
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; }
.singleResult(); serializedValue = ((ObjectValue) historicObjectValue.getTypedValue()).getValueSerialized(); actualJsonTree = objectMapper.readTree(serializedValue); Assert.assertEquals(expectedJsonTree, actualJsonTree);
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; }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testImplicitVariableUpdateAndScopeDestroyedInOneTransaction() { deployment(Bpmn.createExecutableProcess("process1") .startEvent("start") .serviceTask("task1").camundaExpression("${var.setValue(\"newValue\")}") .endEvent("end") .done()); processEngine.getRuntimeService().startProcessInstanceByKey("process1", Variables.createVariables().putValue("var", new CustomVar("initialValue"))); final HistoricVariableInstance historicVariableInstance = processEngine.getHistoryService().createHistoricVariableInstanceQuery().list().get(0); CustomVar var = (CustomVar) historicVariableInstance.getTypedValue().getValue(); assertEquals("newValue", var.getValue()); final List<HistoricDetail> historicDetails = processEngine.getHistoryService().createHistoricDetailQuery().orderPartiallyByOccurrence().desc().list(); HistoricDetail historicDetail = historicDetails.get(0); final CustomVar typedValue = (CustomVar) ((HistoricVariableUpdate) historicDetail).getTypedValue().getValue(); assertEquals("newValue", typedValue.getValue()); }
assertEquals(ValueType.STRING.getName(), historicProcessVariable.getVariableTypeName()); assertEquals(ValueType.STRING.getName(), historicProcessVariable.getTypeName()); assertEquals(historicProcessVariable.getValue(), historicProcessVariable.getTypedValue().getValue()); assertEquals(historicProcessVariable.getTypeName(), historicProcessVariable.getTypedValue().getType().getName());
FileValue typedValue = (FileValue) fileVariableInstance.getTypedValue(); assertNull(typedValue.getValue());
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) { HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService(); List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery() .executionIdIn(processInstance.getId()) .list(); VariableMap variables = new VariableMapImpl(); for (HistoricVariableInstance variable : historicVariables) { variables.putValueTyped(variable.getName(), variable.getTypedValue()); } return variables; }
private void checkVariables(VariableMap map, int expectedSize) { List<HistoricVariableInstance> variables = engineRule.getHistoryService() .createHistoricVariableInstanceQuery() .orderByVariableName() .asc() .list(); assertEquals(expectedSize, variables.size()); assertEquals(variables.size(), map.size()); for (HistoricVariableInstance instance : variables) { assertTrue(map.containsKey(instance.getName())); Object instanceValue = instance.getTypedValue().getValue(); Object mapValue = map.getValueTyped(instance.getName()).getValue(); if (instanceValue == null) { assertNull(mapValue); } else if (instanceValue instanceof byte[]) { assertTrue(Arrays.equals((byte[]) instanceValue, (byte[]) mapValue)); } else { assertEquals(instanceValue, mapValue); } } }
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void testImplicitVariableUpdateAndScopeDestroyedInOneTransaction() { deployment(Bpmn.createExecutableProcess("process1") .startEvent("start") .serviceTask("task1").camundaExpression("${var.setValue(\"newValue\")}") .endEvent("end") .done()); processEngine.getRuntimeService().startProcessInstanceByKey("process1", Variables.createVariables().putValue("var", new CustomVar("initialValue"))); final HistoricVariableInstance historicVariableInstance = processEngine.getHistoryService().createHistoricVariableInstanceQuery().list().get(0); CustomVar var = (CustomVar) historicVariableInstance.getTypedValue().getValue(); assertEquals("newValue", var.getValue()); final List<HistoricDetail> historicDetails = processEngine.getHistoryService().createHistoricDetailQuery().orderPartiallyByOccurrence().desc().list(); HistoricDetail historicDetail = historicDetails.get(0); final CustomVar typedValue = (CustomVar) ((HistoricVariableUpdate) historicDetail).getTypedValue().getValue(); assertEquals("newValue", typedValue.getValue()); }