private void setupHistoryReportMock() { CleanableHistoricDecisionInstanceReport report = mock(typeof(CleanableHistoricDecisionInstanceReport)); when(report.decisionDefinitionIdIn(anyString())).thenReturn(report); when(report.decisionDefinitionKeyIn(anyString())).thenReturn(report); CleanableHistoricDecisionInstanceReportResult reportResult = mock(typeof(CleanableHistoricDecisionInstanceReportResult)); when(reportResult.DecisionDefinitionId).thenReturn(EXAMPLE_DD_ID); when(reportResult.DecisionDefinitionKey).thenReturn(EXAMPLE_DD_KEY); when(reportResult.DecisionDefinitionName).thenReturn(EXAMPLE_DD_NAME); when(reportResult.DecisionDefinitionVersion).thenReturn(EXAMPLE_DD_VERSION); when(reportResult.HistoryTimeToLive).thenReturn(EXAMPLE_TTL); when(reportResult.FinishedDecisionInstanceCount).thenReturn(EXAMPLE_FINISHED_DI_COUNT); when(reportResult.CleanableDecisionInstanceCount).thenReturn(EXAMPLE_CLEANABLE_DI_COUNT); when(reportResult.TenantId).thenReturn(EXAMPLE_TENANT_ID); CleanableHistoricDecisionInstanceReportResult anotherReportResult = mock(typeof(CleanableHistoricDecisionInstanceReportResult)); when(anotherReportResult.DecisionDefinitionId).thenReturn(ANOTHER_EXAMPLE_DD_ID); when(anotherReportResult.DecisionDefinitionKey).thenReturn(ANOTHER_EXAMPLE_DD_KEY); when(anotherReportResult.DecisionDefinitionName).thenReturn("dpName"); when(anotherReportResult.DecisionDefinitionVersion).thenReturn(33); when(anotherReportResult.HistoryTimeToLive).thenReturn(5); when(anotherReportResult.FinishedDecisionInstanceCount).thenReturn(10l); when(anotherReportResult.CleanableDecisionInstanceCount).thenReturn(0l); when(anotherReportResult.TenantId).thenReturn(ANOTHER_EXAMPLE_TENANT_ID); IList <CleanableHistoricDecisionInstanceReportResult> mocks = new List <CleanableHistoricDecisionInstanceReportResult>(); mocks.Add(reportResult); mocks.Add(anotherReportResult); when(report.list()).thenReturn(mocks); when(report.count()).thenReturn((long)mocks.Count); historicDecisionInstanceReport = report; when(processEngine.HistoryService.createCleanableHistoricDecisionInstanceReport()).thenReturn(historicDecisionInstanceReport); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReportComplex() public virtual 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 IList <CleanableHistoricDecisionInstanceReportResult> reportResults = historyService.createCleanableHistoricDecisionInstanceReport().list(); string secondDecisionDefinitionId = repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(SECOND_DECISION_DEFINITION_KEY).singleResult().Id; CleanableHistoricDecisionInstanceReportResult secondReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionIdIn(secondDecisionDefinitionId).singleResult(); CleanableHistoricDecisionInstanceReportResult thirdReportResult = historyService.createCleanableHistoricDecisionInstanceReport().decisionDefinitionKeyIn(THIRD_DECISION_DEFINITION_KEY).singleResult(); // then assertEquals(4, reportResults.Count); foreach (CleanableHistoricDecisionInstanceReportResult result in reportResults) { if (result.DecisionDefinitionKey.Equals(DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 20); } else if (result.DecisionDefinitionKey.Equals(SECOND_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 10); } else if (result.DecisionDefinitionKey.Equals(THIRD_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 10, 10); } else if (result.DecisionDefinitionKey.Equals(FOURTH_DECISION_DEFINITION_KEY)) { checkResultNumbers(result, 0, 0); } } checkResultNumbers(secondReportResult, 0, 10); checkResultNumbers(thirdReportResult, 10, 10); }
private void checkResultNumbers(CleanableHistoricDecisionInstanceReportResult result, int expectedCleanable, int expectedFinished) { assertEquals(expectedCleanable, result.CleanableDecisionInstanceCount); assertEquals(expectedFinished, result.FinishedDecisionInstanceCount); }