@Test
@SuppressWarnings({"unchecked", "rawtypes"})

public void drainQueue() {
  final TasksHolder tasksHolder = new TasksHolder();
  doReturn(false).doReturn(true).when(cacheTasks).isEmpty();
  doAnswer(new Answer() {
    public Object answer(InvocationOnMock invocation) throws Throwable {
      List<CacheTask<Object, Object>> tasks = (List<CacheTask<Object, Object>>) invocation
          .getArguments()[0];
      tasks.add(cacheTask);
      tasksHolder.tasks = tasks;
      return null;
    }
  }).when(cacheTasks).drainTo(anyList(), anyInt());
  doNothing().when(asyncEvictionListener).save(anyList());
  asyncEvictionListener.drainQueue();
  assertEquals(cacheTask, tasksHolder.tasks.get(0));
}