public void clean(final Date now) {
    List<String> files = this.findFiles();
    List<String> expiredFiles = this.filterFiles(files, this.createExpiredFileFilter(now));
    for (String f : expiredFiles) {
      this.delete(new File(f));
    }

    if (this.totalSizeCap != CoreConstants.UNBOUNDED_TOTAL_SIZE_CAP && this.totalSizeCap > 0) {
      this.capTotalSize(files);
    }

    List<String> emptyDirs = this.findEmptyDirs();
    for (String dir : emptyDirs) {
      this.delete(new File(dir));
    }
  }
@Test
  public void removesParentDirWhenEmpty() throws IOException {
    File[] emptyDirs = new File[] {
      tmpDir.newFolder("empty_2018", "08"),
      tmpDir.newFolder("empty_2018", "12"),
      tmpDir.newFolder("empty_2019", "01"),
    };
    for (File d : emptyDirs) {
      d.deleteOnExit();
    }

    remover = mockArchiveRemover(tmpDir.getRoot().getAbsolutePath() + File.separator + "empty_%d{yyyy/MM}" + File.separator + "%d.log", fileProvider);
    remover.clean(EXPIRY);

    for (File d : emptyDirs) {
      verify(fileProvider).deleteFile(d);
    }
  }