DefaultAlertEntityHolder implements AlertEntityHolder { @Override public synchronized void hold(AlertEntity alertEntity) { if(!alertEntity.getAlertType().equals(alertType)) { throw new IllegalArgumentException(String.format("need alert type: %s, but receive: %s", alertType.name(), alertEntity.getAlertType().name())); } alerts.remove(alertEntity); alerts.add(alertEntity); } 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(expected = IllegalArgumentException.class) public void hold() { holder.hold(new AlertEntity(null, null, null, null, null, ALERT_TYPE.CLIENT_INSTANCE_NOT_OK)); }