use of org.sonar.db.purge.PurgeDao in project sonarqube by SonarSource.
the class DefaultPeriodCleanerTest method doClean.
@Test
public void doClean() {
PurgeDao dao = mock(PurgeDao.class);
DbSession session = mock(DbSession.class);
when(dao.selectPurgeableAnalyses("uuid_123", session)).thenReturn(Arrays.asList(new PurgeableAnalysisDto().setAnalysisId(999).setAnalysisUuid("u999").setDate(System2.INSTANCE.now()), new PurgeableAnalysisDto().setAnalysisId(456).setAnalysisUuid("u456").setDate(System2.INSTANCE.now())));
Filter filter1 = newFirstSnapshotInListFilter();
Filter filter2 = newFirstSnapshotInListFilter();
PurgeProfiler profiler = new PurgeProfiler();
DefaultPeriodCleaner cleaner = new DefaultPeriodCleaner(dao, profiler);
cleaner.doClean("uuid_123", Arrays.asList(filter1, filter2), session);
InOrder inOrder = Mockito.inOrder(dao, filter1, filter2);
inOrder.verify(filter1).log();
inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of(new IdUuidPair(999, "u999"))));
inOrder.verify(filter2).log();
inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of(new IdUuidPair(456, "u456"))));
inOrder.verifyNoMoreInteractions();
}
Aggregations