@Test
public void testProcessEvictableResource() throws Exception {

  FileSystem fs = mock(FileSystem.class);
  CleanerMetrics metrics = mock(CleanerMetrics.class);
  SCMStore store = mock(SCMStore.class);
  CleanerTask task =
      createSpiedTask(fs, store, metrics, new ReentrantLock());
  // mock an evictable resource
  when(store.isResourceEvictable(isA(String.class), isA(FileStatus.class)))
      .thenReturn(true);
  FileStatus status = mock(FileStatus.class);
  when(status.getPath()).thenReturn(new Path(ROOT + "/a/b/c/abc"));
  when(store.removeResource(isA(String.class))).thenReturn(true);
  // rename succeeds
  when(fs.rename(isA(Path.class), isA(Path.class))).thenReturn(true);
  // delete returns true
  when(fs.delete(isA(Path.class), anyBoolean())).thenReturn(true);
  // process the resource
  task.processSingleResource(status);
  // the directory should be renamed
  verify(fs).rename(eq(status.getPath()), isA(Path.class));
  // metrics should record a deleted file
  verify(metrics).reportAFileDelete();
  verify(metrics, never()).reportAFileProcess();
}