public static HistoricDecisionInstance createMockHistoricDecisionInstanceBase(String tenantId) { HistoricDecisionInstance mock = mock(HistoricDecisionInstance.class); when(mock.getId()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_ID); when(mock.getDecisionDefinitionId()).thenReturn(EXAMPLE_DECISION_DEFINITION_ID); when(mock.getDecisionDefinitionKey()).thenReturn(EXAMPLE_DECISION_DEFINITION_KEY); when(mock.getDecisionDefinitionName()).thenReturn(EXAMPLE_DECISION_DEFINITION_NAME); when(mock.getProcessDefinitionId()).thenReturn(EXAMPLE_PROCESS_DEFINITION_ID); when(mock.getProcessDefinitionKey()).thenReturn(EXAMPLE_PROCESS_DEFINITION_KEY); when(mock.getProcessInstanceId()).thenReturn(EXAMPLE_PROCESS_INSTANCE_ID); when(mock.getCaseDefinitionId()).thenReturn(EXAMPLE_CASE_DEFINITION_ID); when(mock.getCaseDefinitionKey()).thenReturn(EXAMPLE_CASE_DEFINITION_KEY); when(mock.getCaseInstanceId()).thenReturn(EXAMPLE_CASE_INSTANCE_ID); when(mock.getActivityId()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_ACTIVITY_ID); when(mock.getActivityInstanceId()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_ACTIVITY_INSTANCE_ID); when(mock.getEvaluationTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_DECISION_INSTANCE_EVALUATION_TIME)); when(mock.getRemovalTime()).thenReturn(DateTimeUtil.parseDate(EXAMPLE_HISTORIC_DECISION_INSTANCE_REMOVAL_TIME)); when(mock.getUserId()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_USER_ID); when(mock.getCollectResultValue()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_COLLECT_RESULT_VALUE); when(mock.getRootDecisionInstanceId()).thenReturn(EXAMPLE_HISTORIC_DECISION_INSTANCE_ID); when(mock.getRootProcessInstanceId()).thenReturn(EXAMPLE_ROOT_HISTORIC_PROCESS_INSTANCE_ID); when(mock.getDecisionRequirementsDefinitionId()).thenReturn(EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_ID); when(mock.getDecisionRequirementsDefinitionKey()).thenReturn(EXAMPLE_DECISION_REQUIREMENTS_DEFINITION_KEY); when(mock.getTenantId()).thenReturn(tenantId); return mock; }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveStandaloneHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionKey("dish-decision") .singleResult(); repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5); // when decisionService.evaluateDecisionTableByKey("dish-decision", Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
assertThat(historicDecisionInstances.get(0).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(1).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(2).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime));
dto.decisionDefinitionName = historicDecisionInstance.getDecisionDefinitionName(); dto.evaluationTime = historicDecisionInstance.getEvaluationTime(); dto.removalTime = historicDecisionInstance.getRemovalTime(); dto.processDefinitionId = historicDecisionInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicDecisionInstance.getProcessDefinitionKey();
dto.decisionDefinitionName = historicDecisionInstance.getDecisionDefinitionName(); dto.evaluationTime = historicDecisionInstance.getEvaluationTime(); dto.removalTime = historicDecisionInstance.getRemovalTime(); dto.processDefinitionId = historicDecisionInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicDecisionInstance.getProcessDefinitionKey();
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveStandaloneHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); DecisionDefinition decisionDefinition = repositoryService.createDecisionDefinitionQuery() .decisionDefinitionKey("dish-decision") .singleResult(); repositoryService.updateDecisionDefinitionHistoryTimeToLive(decisionDefinition.getId(), 5); // when decisionService.evaluateDecisionTableByKey("dish-decision", Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldResolveHistoricDecisionInstance() { // given ClockUtil.setCurrentTime(START_DATE); testRule.deploy(Bpmn.createExecutableProcess(CALLING_PROCESS_KEY) .camundaHistoryTimeToLive(5) .startEvent() .businessRuleTask() .camundaDecisionRef("dish-decision") .endEvent().done()); // when runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list(); // assume assertThat(historicDecisionInstances.size(), is(3)); Date removalTime = addDays(START_DATE, 5); // then assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime)); }
assertThat(historicDecisionInstances.get(0).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(1).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(2).getRemovalTime(), nullValue()); assertThat(historicDecisionInstances.get(0).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(1).getRemovalTime(), is(removalTime)); assertThat(historicDecisionInstances.get(2).getRemovalTime(), is(removalTime));
dto.decisionDefinitionName = historicDecisionInstance.getDecisionDefinitionName(); dto.evaluationTime = historicDecisionInstance.getEvaluationTime(); dto.removalTime = historicDecisionInstance.getRemovalTime(); dto.processDefinitionId = historicDecisionInstance.getProcessDefinitionId(); dto.processDefinitionKey = historicDecisionInstance.getProcessDefinitionKey();