@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldNotSeeCleanableDecisionInstancesInReport() { // given engineConfiguration .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END) .initHistoryRemovalTime(); testRule.deploy(CALLING_PROCESS_CALLS_DMN); ClockUtil.setCurrentTime(END_DATE); for (int i = 0; i < 5; i++) { runtimeService.startProcessInstanceByKey(CALLING_PROCESS_CALLS_DMN_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); } ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when CleanableHistoricDecisionInstanceReportResult report = historyService.createCleanableHistoricDecisionInstanceReport() .decisionDefinitionKeyIn("dish-decision") .compact() .singleResult(); // then assertThat(report.getCleanableDecisionInstanceCount(), is(0L)); assertThat(report.getFinishedDecisionInstanceCount(), is(5L)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldSeeCleanableDecisionInstancesInReport() { // given engineConfiguration .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_START) .initHistoryRemovalTime(); testRule.deploy(CALLING_PROCESS_CALLS_DMN); ClockUtil.setCurrentTime(END_DATE); for (int i = 0; i < 5; i++) { runtimeService.startProcessInstanceByKey(CALLING_PROCESS_CALLS_DMN_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); } ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when CleanableHistoricDecisionInstanceReportResult report = historyService.createCleanableHistoricDecisionInstanceReport() .decisionDefinitionKeyIn("dish-decision") .compact() .singleResult(); // then assertThat(report.getCleanableDecisionInstanceCount(), is(5L)); assertThat(report.getFinishedDecisionInstanceCount(), is(5L)); }
@Test public void testReportComplex() { // given testRule.deploy("org/camunda/bpm/engine/test/repository/two.dmn", "org/camunda/bpm/engine/test/api/dmn/Another_Example.dmn", "org/camunda/bpm/engine/test/api/dmn/Example.dmn"); prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, 5, 10); prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); prepareDecisionInstances(SECOND_DECISION_DEFINITION_KEY, -6, null, 10); prepareDecisionInstances(THIRD_DECISION_DEFINITION_KEY, -6, 5, 10); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); String secondDecisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(SECOND_DECISION_DEFINITION_KEY).singleResult().getId(); CleanableHistoricDecisionInstanceReportResult secondReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionIdIn(secondDecisionDefinitionId).singleResult(); CleanableHistoricDecisionInstanceReportResult thirdReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionKeyIn(THIRD_DECISION_DEFINITION_KEY).singleResult(); // then assertEquals(4, reportResults.size()); for (CleanableHistoricDecisionInstanceReportResult result : reportResults) { if (result.getDecisionDefinitionKey().equals(DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 20); } else if (result.getDecisionDefinitionKey().equals(SECOND_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 10); } else if (result.getDecisionDefinitionKey().equals(THIRD_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 10); } else if (result.getDecisionDefinitionKey().equals(FOURTH_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 0); } } checkResultNumbers(secondReportResult, 0, 10); checkResultNumbers(thirdReportResult, 10, 10); }
@Test public void testReportComplex() { // given testRule.deploy("org/camunda/bpm/engine/test/repository/two.dmn", "org/camunda/bpm/engine/test/api/dmn/Another_Example.dmn", "org/camunda/bpm/engine/test/api/dmn/Example.dmn"); prepareDecisionInstances(DECISION_DEFINITION_KEY, 0, 5, 10); prepareDecisionInstances(DECISION_DEFINITION_KEY, -6, 5, 10); prepareDecisionInstances(SECOND_DECISION_DEFINITION_KEY, -6, null, 10); prepareDecisionInstances(THIRD_DECISION_DEFINITION_KEY, -6, 5, 10); // when List<CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); String secondDecisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(SECOND_DECISION_DEFINITION_KEY).singleResult().getId(); CleanableHistoricDecisionInstanceReportResult secondReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionIdIn(secondDecisionDefinitionId).singleResult(); CleanableHistoricDecisionInstanceReportResult thirdReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionKeyIn(THIRD_DECISION_DEFINITION_KEY).singleResult(); // then assertEquals(4, reportResults.size()); for (CleanableHistoricDecisionInstanceReportResult result : reportResults) { if (result.getDecisionDefinitionKey().equals(DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 20); } else if (result.getDecisionDefinitionKey().equals(SECOND_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 10); } else if (result.getDecisionDefinitionKey().equals(THIRD_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 10); } else if (result.getDecisionDefinitionKey().equals(FOURTH_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 0); } } checkResultNumbers(secondReportResult, 0, 10); checkResultNumbers(thirdReportResult, 10, 10); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldNotSeeCleanableDecisionInstances() { // given engineConfiguration .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END) .initHistoryRemovalTime(); testRule.deploy(CALLING_PROCESS_CALLS_DMN); ClockUtil.setCurrentTime(END_DATE); for (int i = 0; i < 5; i++) { runtimeService.startProcessInstanceByKey(CALLING_PROCESS_CALLS_DMN_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); } ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when CleanableHistoricDecisionInstanceReportResult report = historyService.createCleanableHistoricDecisionInstanceReport() .decisionDefinitionKeyIn("dish-decision") .compact() .singleResult(); // then assertThat(report.getCleanableDecisionInstanceCount(), is(0L)); }
@Test @Deployment(resources = { "org/camunda/bpm/engine/test/dmn/deployment/drdDish.dmn11.xml" }) public void shouldSeeCleanableDecisionInstances() { // given engineConfiguration .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_START) .initHistoryRemovalTime(); testRule.deploy(CALLING_PROCESS_CALLS_DMN); ClockUtil.setCurrentTime(END_DATE); for (int i = 0; i < 5; i++) { runtimeService.startProcessInstanceByKey(CALLING_PROCESS_CALLS_DMN_KEY, Variables.createVariables() .putValue("temperature", 32) .putValue("dayType", "Weekend")); } ClockUtil.setCurrentTime(addDays(END_DATE, 5)); // when CleanableHistoricDecisionInstanceReportResult report = historyService.createCleanableHistoricDecisionInstanceReport() .decisionDefinitionKeyIn("dish-decision") .compact() .singleResult(); // then assertThat(report.getCleanableDecisionInstanceCount(), is(5L)); }