private void assertThatUpdateHasAllImportantInformation(HistoricVariableUpdate variableUpdate) { assertThat(variableUpdate, notNullValue()); assertThat(variableUpdate.getId(), notNullValue()); assertThat(variableUpdate.getProcessDefinitionKey(), is("process")); assertThat(variableUpdate.getProcessDefinitionId(), notNullValue()); assertThat(variableUpdate.getVariableName(), is("stringVar")); assertThat(variableUpdate.getValue().toString(), is("foo")); assertThat(variableUpdate.getTypeName(), is("string")); assertThat(variableUpdate.getTime(), notNullValue()); }
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()); } }
when(mockVariable.getTaskId()).thenReturn(taskId); when(mockVariable.getExecutionId()).thenReturn(executionId); when(mockVariable.getTypeName()).thenReturn(typedValue.getType().getName()); when(mockVariable.getCaseDefinitionKey()).thenReturn(caseDefinitionKey); when(mockVariable.getCaseDefinitionId()).thenReturn(caseDefinitionId);
if (detail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) detail; assertTrue(allowedVariableTypes.contains(variableUpdate.getTypeName())); } else { fail("Historic detail should be a variable update!");
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testQueryByVariableTypeIn() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("boolVar", true); runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); // when HistoricDetailQuery query = historyService.createHistoricDetailQuery() .variableTypeIn("string"); // then assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricDetail historicDetail = query.list().get(0); if (historicDetail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicDetail; assertEquals(variableUpdate.getVariableName(), "stringVar"); assertEquals(variableUpdate.getTypeName(), "string"); } else { fail("Historic detail should be a variable update!"); } }
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testQueryByVariableTypeInWithCapitalLetter() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("boolVar", true); runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); // when HistoricDetailQuery query = historyService.createHistoricDetailQuery() .variableTypeIn("Boolean"); // then assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricDetail historicDetail = query.list().get(0); if (historicDetail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicDetail; assertEquals(variableUpdate.getVariableName(), "boolVar"); assertEquals(variableUpdate.getTypeName(), "boolean"); } else { fail("Historic detail should be a variable update!"); } }
private void assertThatUpdateHasAllImportantInformation(HistoricVariableUpdate variableUpdate) { assertThat(variableUpdate, notNullValue()); assertThat(variableUpdate.getId(), notNullValue()); assertThat(variableUpdate.getProcessDefinitionKey(), is("process")); assertThat(variableUpdate.getProcessDefinitionId(), notNullValue()); assertThat(variableUpdate.getVariableName(), is("stringVar")); assertThat(variableUpdate.getValue().toString(), is("foo")); assertThat(variableUpdate.getTypeName(), is("string")); assertThat(variableUpdate.getTime(), notNullValue()); }
@Test public void testHistoricDetailQueryById() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "someName"; String variableValue = "someValue"; taskService.setVariable(newTask.getId(), variableName, variableValue); HistoricDetail result = historyService.createHistoricDetailQuery() .singleResult(); HistoricDetail resultById = historyService.createHistoricDetailQuery().detailId(result.getId()).singleResult(); assertNotNull(resultById); assertEquals(result.getId(), resultById.getId()); assertEquals(variableName, ((HistoricVariableUpdate)resultById).getVariableName()); assertEquals(variableValue, ((HistoricVariableUpdate)resultById).getValue()); assertEquals(ValueType.STRING.getName(), ((HistoricVariableUpdate)resultById).getVariableTypeName()); assertEquals(ValueType.STRING.getName(), ((HistoricVariableUpdate)resultById).getTypeName()); 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()); } }
if (detail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) detail; assertTrue(allowedVariableTypes.contains(variableUpdate.getTypeName())); } else { fail("Historic detail should be a variable update!");
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testQueryByVariableTypeIn() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("boolVar", true); runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); // when HistoricDetailQuery query = historyService.createHistoricDetailQuery() .variableTypeIn("string"); // then assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricDetail historicDetail = query.list().get(0); if (historicDetail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicDetail; assertEquals(variableUpdate.getVariableName(), "stringVar"); assertEquals(variableUpdate.getTypeName(), "string"); } else { fail("Historic detail should be a variable update!"); } }
@Test @Deployment(resources={"org/camunda/bpm/engine/test/api/runtime/oneTaskProcess.bpmn20.xml"}) public void testQueryByVariableTypeInWithCapitalLetter() { // given Map<String, Object> variables1 = new HashMap<String, Object>(); variables1.put("stringVar", "test"); variables1.put("boolVar", true); runtimeService.startProcessInstanceByKey("oneTaskProcess", variables1); // when HistoricDetailQuery query = historyService.createHistoricDetailQuery() .variableTypeIn("Boolean"); // then assertEquals(1, query.list().size()); assertEquals(1, query.count()); HistoricDetail historicDetail = query.list().get(0); if (historicDetail instanceof HistoricVariableUpdate) { HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) historicDetail; assertEquals(variableUpdate.getVariableName(), "boolVar"); assertEquals(variableUpdate.getTypeName(), "boolean"); } else { fail("Historic detail should be a variable update!"); } }
@Test public void testHistoricDetailQueryById() { Task newTask = taskService.newTask(); taskService.saveTask(newTask); String variableName = "someName"; String variableValue = "someValue"; taskService.setVariable(newTask.getId(), variableName, variableValue); HistoricDetail result = historyService.createHistoricDetailQuery() .singleResult(); HistoricDetail resultById = historyService.createHistoricDetailQuery().detailId(result.getId()).singleResult(); assertNotNull(resultById); assertEquals(result.getId(), resultById.getId()); assertEquals(variableName, ((HistoricVariableUpdate)resultById).getVariableName()); assertEquals(variableValue, ((HistoricVariableUpdate)resultById).getValue()); assertEquals(ValueType.STRING.getName(), ((HistoricVariableUpdate)resultById).getVariableTypeName()); assertEquals(ValueType.STRING.getName(), ((HistoricVariableUpdate)resultById).getTypeName()); taskService.deleteTask(newTask.getId(), true); }