BasicEvictionListener implements AsyncEvictionListener<K, V> { public void onEviction(final K key, final V value) { asyncEvictionExecutor.execute(() -> save(key, value)); } BasicEvictionListener(); void onEviction(final K key, final V value); abstract void save(K key, V value);  }
@Test public void onEviction() { Object key = new Object(), value = new Object(); doNothing().when(asyncEvictionListener).save(key, value); asyncEvictionListener.onEviction(key, value); try { Thread.sleep(10); } catch (InterruptedException e) { } verify(asyncEvictionListener).save(key, value); }