ScheduledEvictionListener extends QueuingEvictionListener<K, V> { @Override protected void drainQueue() { while (!cacheTasks.isEmpty()) { super.drainQueue(); } } ScheduledEvictionListener();  ScheduledEvictionListener(final int batchSize, final long period, final int queueSize);  static final long DEFAULT_PERIOD; }
@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)); }