when(mockVariable.getProcessInstanceId()).thenReturn(processInstanceId); when(mockVariable.getErrorMessage()).thenReturn(errorMessage); when(mockVariable.getRevision()).thenReturn(revision); when(mockVariable.getTime()).thenReturn(DateTimeUtil.parseDate(time)); when(mockVariable.getActivityInstanceId()).thenReturn(activityInstanceId);
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()); } }
assertEquals("bytes", historicVariableUpdate.getVariableName()); assertEquals(":-(", new String((byte[])historicVariableUpdate.getValue())); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("bytes", historicVariableUpdate.getVariableName()); assertEquals(":-)", new String((byte[])historicVariableUpdate.getValue())); assertEquals(1, historicVariableUpdate.getRevision()); assertEquals(waitStateActivity.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("character", historicVariableUpdate.getVariableName()); assertEquals("a", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("number", historicVariableUpdate.getVariableName()); assertEquals("one", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("number", historicVariableUpdate.getVariableName()); assertEquals("two", historicVariableUpdate.getValue()); assertEquals(1, historicVariableUpdate.getRevision()); assertEquals(waitStateActivity.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("zVar1", historicVariableUpdate.getVariableName()); assertEquals("Event: start", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId());
@Deployment public void testHistoricVariableInstanceRevision() { // given: // a finished process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); assertProcessEnded(processInstance.getId()); // when // then HistoricVariableInstance variable = historyService .createHistoricVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) variable; // the revision has to be 0 assertEquals(0, variableEntity.getRevision()); if (isFullHistoryEnabled()) { List<HistoricDetail> details = historyService .createHistoricDetailQuery() .orderByVariableRevision() .asc() .list(); for (HistoricDetail detail : details) { HistoricVariableUpdate variableDetail = (HistoricVariableUpdate) detail; assertEquals(0, variableDetail.getRevision()); } } }
@Deployment public void testHistoricVariableInstanceRevisionAsync() { // given: // a finished process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); // when executeAvailableJobs(); // then assertProcessEnded(processInstance.getId()); HistoricVariableInstance variable = historyService .createHistoricVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) variable; // the revision has to be 2 assertEquals(2, variableEntity.getRevision()); if (isFullHistoryEnabled()) { List<HistoricDetail> details = historyService .createHistoricDetailQuery() .orderByVariableRevision() .asc() .list(); int i = 0; for (HistoricDetail detail : details) { HistoricVariableUpdate variableDetail = (HistoricVariableUpdate) detail; assertEquals(i, variableDetail.getRevision()); i++; } } }
assertEquals("aVariable", startVarUpdate.getVariableName()); assertEquals("initial value", startVarUpdate.getValue()); assertEquals(0, startVarUpdate.getRevision()); assertEquals(processInstance.getId(), startVarUpdate.getProcessInstanceId());
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()); } }
assertEquals("bytes", historicVariableUpdate.getVariableName()); assertEquals(":-(", new String((byte[])historicVariableUpdate.getValue())); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("bytes", historicVariableUpdate.getVariableName()); assertEquals(":-)", new String((byte[])historicVariableUpdate.getValue())); assertEquals(1, historicVariableUpdate.getRevision()); assertEquals(waitStateActivity.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("character", historicVariableUpdate.getVariableName()); assertEquals("a", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("number", historicVariableUpdate.getVariableName()); assertEquals("one", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("number", historicVariableUpdate.getVariableName()); assertEquals("two", historicVariableUpdate.getValue()); assertEquals(1, historicVariableUpdate.getRevision()); assertEquals(waitStateActivity.getId(), historicVariableUpdate.getActivityInstanceId()); assertEquals("zVar1", historicVariableUpdate.getVariableName()); assertEquals("Event: start", historicVariableUpdate.getValue()); assertEquals(0, historicVariableUpdate.getRevision()); assertEquals(historicStartEvent.getId(), historicVariableUpdate.getActivityInstanceId());
@Deployment public void testHistoricVariableInstanceRevision() { // given: // a finished process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); assertProcessEnded(processInstance.getId()); // when // then HistoricVariableInstance variable = historyService .createHistoricVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) variable; // the revision has to be 0 assertEquals(0, variableEntity.getRevision()); if (isFullHistoryEnabled()) { List<HistoricDetail> details = historyService .createHistoricDetailQuery() .orderByVariableRevision() .asc() .list(); for (HistoricDetail detail : details) { HistoricVariableUpdate variableDetail = (HistoricVariableUpdate) detail; assertEquals(0, variableDetail.getRevision()); } } }
@Deployment public void testHistoricVariableInstanceRevisionAsync() { // given: // a finished process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); // when executeAvailableJobs(); // then assertProcessEnded(processInstance.getId()); HistoricVariableInstance variable = historyService .createHistoricVariableInstanceQuery() .singleResult(); assertNotNull(variable); HistoricVariableInstanceEntity variableEntity = (HistoricVariableInstanceEntity) variable; // the revision has to be 2 assertEquals(2, variableEntity.getRevision()); if (isFullHistoryEnabled()) { List<HistoricDetail> details = historyService .createHistoricDetailQuery() .orderByVariableRevision() .asc() .list(); int i = 0; for (HistoricDetail detail : details) { HistoricVariableUpdate variableDetail = (HistoricVariableUpdate) detail; assertEquals(i, variableDetail.getRevision()); i++; } } }
assertEquals("aVariable", startVarUpdate.getVariableName()); assertEquals("initial value", startVarUpdate.getValue()); assertEquals(0, startVarUpdate.getRevision()); assertEquals(processInstance.getId(), startVarUpdate.getProcessInstanceId());