Example #1
0
        private void setupHistoryReportMock()
        {
            CleanableHistoricBatchReport report = mock(typeof(CleanableHistoricBatchReport));

            CleanableHistoricBatchReportResult reportResult = mock(typeof(CleanableHistoricBatchReportResult));

            when(reportResult.BatchType).thenReturn(EXAMPLE_TYPE);
            when(reportResult.HistoryTimeToLive).thenReturn(EXAMPLE_TTL);
            when(reportResult.FinishedBatchesCount).thenReturn(EXAMPLE_FINISHED_COUNT);
            when(reportResult.CleanableBatchesCount).thenReturn(EXAMPLE_CLEANABLE_COUNT);

            CleanableHistoricBatchReportResult anotherReportResult = mock(typeof(CleanableHistoricBatchReportResult));

            when(anotherReportResult.BatchType).thenReturn("batchId2");
            when(anotherReportResult.HistoryTimeToLive).thenReturn(null);
            when(anotherReportResult.FinishedBatchesCount).thenReturn(13l);
            when(anotherReportResult.CleanableBatchesCount).thenReturn(0l);

            IList <CleanableHistoricBatchReportResult> mocks = new List <CleanableHistoricBatchReportResult>();

            mocks.Add(reportResult);
            mocks.Add(anotherReportResult);

            when(report.list()).thenReturn(mocks);
            when(report.count()).thenReturn((long)mocks.Count);

            historicBatchReport = report;
            when(processEngine.HistoryService.createCleanableHistoricBatchReport()).thenReturn(historicBatchReport);
        }
Example #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testReportZeroTTL()
        public virtual void testReportZeroTTL()
        {
            IDictionary <string, string> map = new Dictionary <string, string>();
            int modOperationsTTL             = 0;

            map["instance-modification"] = "P0D";
            processEngineConfiguration.BatchOperationsForHistoryCleanup = map;
            processEngineConfiguration.initHistoryCleanup();

            DateTime startDate     = ClockUtil.CurrentTime;
            int      daysInThePast = -11;

            ClockUtil.CurrentTime = DateUtils.addDays(startDate, daysInThePast);

            Batch modificationBatch = createModificationBatch();

            ClockUtil.CurrentTime = DateUtils.addDays(startDate, -7);

            managementService.deleteBatch(modificationBatch.Id, false);

            CleanableHistoricBatchReportResult result = historyService.createCleanableHistoricBatchReport().singleResult();

            assertNotNull(result);
            checkResultNumbers(result, 1, 1, modOperationsTTL);
        }
Example #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testHistoryCleanupReportQueryWithPermissions()
        public virtual void testHistoryCleanupReportQueryWithPermissions()
        {
            // given
            authRule.createGrantAuthorization(Resources.BATCH, "*", "user", Permissions.READ_HISTORY);
            string migrationOperationsTTL = "P0D";

            prepareBatch(migrationOperationsTTL);

            authRule.enableAuthorization("user");
            CleanableHistoricBatchReportResult result = engineRule.HistoryService.createCleanableHistoricBatchReport().singleResult();

            authRule.disableAuthorization();

            assertNotNull(result);
            checkResultNumbers(result, 1, 1, 0);
        }
Example #4
0
 private void checkResultNumbers(CleanableHistoricBatchReportResult result, int expectedCleanable, int expectedFinished, int?expectedTTL)
 {
     assertEquals(expectedCleanable, result.CleanableBatchesCount);
     assertEquals(expectedFinished, result.FinishedBatchesCount);
     assertEquals(expectedTTL, result.HistoryTimeToLive);
 }