@VisibleForTesting
  void doClean(String rootUuid, List<Filter> filters, DbSession session) {
    List<PurgeableAnalysisDto> history = new ArrayList<>(selectAnalysesOfComponent(rootUuid, session));
    for (Filter filter : filters) {
      filter.log();
      List<PurgeableAnalysisDto> toDelete = filter.filter(history);
      List<PurgeableAnalysisDto> deleted = delete(rootUuid, toDelete, session);
      history.removeAll(deleted);
    }
  }
@Test
  void doClean() {
    PurgeDao dao = mock(PurgeDao.class);
    DbSession session = mock(DbSession.class);
    when(dao.selectProcessedAnalysisByComponentUuid("uuid_123", session)).thenReturn(Arrays.asList(
      new PurgeableAnalysisDto().setAnalysisUuid("u999").setDate(System2.INSTANCE.now()),
      new PurgeableAnalysisDto().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(session, profiler, ImmutableList.of("u999"));
    inOrder.verify(filter2).log();
    inOrder.verify(dao, times(1)).deleteAnalyses(session, profiler, ImmutableList.of("u456"));
    inOrder.verifyNoMoreInteractions();
  }