private void setupHistoryReportMock() { CleanableHistoricCaseInstanceReport report = mock(typeof(CleanableHistoricCaseInstanceReport)); when(report.caseDefinitionIdIn(anyString())).thenReturn(report); when(report.caseDefinitionKeyIn(anyString())).thenReturn(report); CleanableHistoricCaseInstanceReportResult reportResult = mock(typeof(CleanableHistoricCaseInstanceReportResult)); when(reportResult.CaseDefinitionId).thenReturn(EXAMPLE_CD_ID); when(reportResult.CaseDefinitionKey).thenReturn(EXAMPLE_CD_KEY); when(reportResult.CaseDefinitionName).thenReturn(EXAMPLE_CD_NAME); when(reportResult.CaseDefinitionVersion).thenReturn(EXAMPLE_CD_VERSION); when(reportResult.HistoryTimeToLive).thenReturn(EXAMPLE_TTL); when(reportResult.FinishedCaseInstanceCount).thenReturn(EXAMPLE_FINISHED_CI_COUNT); when(reportResult.CleanableCaseInstanceCount).thenReturn(EXAMPLE_CLEANABLE_CI_COUNT); when(reportResult.TenantId).thenReturn(EXAMPLE_TENANT_ID); CleanableHistoricCaseInstanceReportResult anotherReportResult = mock(typeof(CleanableHistoricCaseInstanceReportResult)); when(anotherReportResult.CaseDefinitionId).thenReturn(ANOTHER_EXAMPLE_CD_ID); when(anotherReportResult.CaseDefinitionKey).thenReturn(ANOTHER_EXAMPLE_CD_KEY); when(anotherReportResult.CaseDefinitionName).thenReturn("cdName"); when(anotherReportResult.CaseDefinitionVersion).thenReturn(33); when(anotherReportResult.HistoryTimeToLive).thenReturn(null); when(anotherReportResult.FinishedCaseInstanceCount).thenReturn(13l); when(anotherReportResult.CleanableCaseInstanceCount).thenReturn(0l); when(anotherReportResult.TenantId).thenReturn(ANOTHER_EXAMPLE_TENANT_ID); IList <CleanableHistoricCaseInstanceReportResult> mocks = new List <CleanableHistoricCaseInstanceReportResult>(); mocks.Add(reportResult); mocks.Add(anotherReportResult); when(report.list()).thenReturn(mocks); when(report.count()).thenReturn((long)mocks.Count); historicCaseInstanceReport = report; when(processEngine.HistoryService.createCleanableHistoricCaseInstanceReport()).thenReturn(historicCaseInstanceReport); }
//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/api/cmmn/oneCaseTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCase.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithHistoryTimeToLive.cmmn"); prepareCaseInstances(CASE_DEFINITION_KEY, 0, 5, 10); prepareCaseInstances(CASE_DEFINITION_KEY, -6, 5, 10); prepareCaseInstances(SECOND_CASE_DEFINITION_KEY, -6, null, 10); prepareCaseInstances(THIRD_CASE_DEFINITION_KEY, -6, 5, 10); // when IList <CleanableHistoricCaseInstanceReportResult> reportResults = historyService.createCleanableHistoricCaseInstanceReport().list(); string id = repositoryService.createCaseDefinitionQuery().caseDefinitionKey(SECOND_CASE_DEFINITION_KEY).singleResult().Id; CleanableHistoricCaseInstanceReportResult secondReportResult = historyService.createCleanableHistoricCaseInstanceReport().caseDefinitionIdIn(id).singleResult(); CleanableHistoricCaseInstanceReportResult thirdReportResult = historyService.createCleanableHistoricCaseInstanceReport().caseDefinitionKeyIn(THIRD_CASE_DEFINITION_KEY).singleResult(); // then assertEquals(4, reportResults.Count); foreach (CleanableHistoricCaseInstanceReportResult result in reportResults) { if (result.CaseDefinitionKey.Equals(CASE_DEFINITION_KEY)) { checkResultNumbers(result, 10, 20); } else if (result.CaseDefinitionKey.Equals(SECOND_CASE_DEFINITION_KEY)) { checkResultNumbers(result, 0, 10); } else if (result.CaseDefinitionKey.Equals(THIRD_CASE_DEFINITION_KEY)) { checkResultNumbers(result, 10, 10); } else if (result.CaseDefinitionKey.Equals(FORTH_CASE_DEFINITION_KEY)) { checkResultNumbers(result, 0, 0); } } checkResultNumbers(secondReportResult, 0, 10); checkResultNumbers(thirdReportResult, 10, 10); }
private void checkResultNumbers(CleanableHistoricCaseInstanceReportResult result, int expectedCleanable, int expectedFinished) { assertEquals(expectedCleanable, result.CleanableCaseInstanceCount); assertEquals(expectedFinished, result.FinishedCaseInstanceCount); }