DefaultAlertEntityHolder implements AlertEntityHolder { @Override public synchronized void removeIf(Predicate<AlertEntity> predicate) { alerts.removeIf(predicate); } DefaultAlertEntityHolder(ALERT_TYPE alertType); @Override ALERT_TYPE getAlertType(); @Override synchronized void hold(AlertEntity alertEntity); @Override boolean remove(AlertEntity alertEntity); @Override synchronized void removeIf(Predicate<AlertEntity> predicate); @Override synchronized boolean hasAlerts(); @Override List<AlertEntity> allAlerts(); @Override String toString();  }
@Test public void removeIf() { final int nearlyTheSameTime = 50; holder.hold(alertEntity()); holder.removeIf(alertEntity -> System.currentTimeMillis() - alertEntity.getDate().getTime() <= nearlyTheSameTime); Assert.assertFalse(holder.hasAlerts()); }