use of org.sonar.db.purge.IdUuidPair 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();
}
use of org.sonar.db.purge.IdUuidPair in project sonarqube by SonarSource.
the class PurgeDatastoresStep method execute.
private void execute(Component root) {
try (DbSession dbSession = dbClient.openSession(true)) {
IdUuidPair idUuidPair = new IdUuidPair(dbIdsRepository.getComponentId(root), root.getUuid());
projectCleaner.purge(dbSession, idUuidPair, settingsRepository.getSettings(root), disabledComponentsHolder.getUuids());
dbSession.commit();
}
}
use of org.sonar.db.purge.IdUuidPair in project sonarqube by SonarSource.
the class PurgeDatastoresStepTest method verify_call_purge_method_of_the_purge_task.
private void verify_call_purge_method_of_the_purge_task(Component project) {
treeRootHolder.setRoot(project);
when(settingsRepository.getSettings(project)).thenReturn(new MapSettings());
dbIdsRepository.setComponentId(project, PROJECT_ID);
underTest.execute();
ArgumentCaptor<IdUuidPair> argumentCaptor = ArgumentCaptor.forClass(IdUuidPair.class);
verify(projectCleaner).purge(any(DbSession.class), argumentCaptor.capture(), any(Settings.class), anyList());
assertThat(argumentCaptor.getValue().getId()).isEqualTo(PROJECT_ID);
assertThat(argumentCaptor.getValue().getUuid()).isEqualTo(PROJECT_UUID);
}
Aggregations