### Question:
InMemoryAlertManager implements AlertManager { @Override public Iterator<Alert> getAlerts(AlertCriteria criteria) { BaseAlertCriteria predicate = (BaseAlertCriteria) (criteria == null ? criteria() : criteria); return this.alertsByTime.values().stream() .map(ref -> (Alert) ref.get()) .filter(predicate) .iterator(); } InMemoryAlertManager(); @Override ID getId(); void setReceiversExecutor(Executor receiversExecutor); @Override Set<AlertDescriptor> getAlertDescriptors(); void setAlertDescriptors(Collection<AlertDescriptor> types); @Override void updateLastUpdatedTime(); @Override boolean addDescriptor(AlertDescriptor descriptor); @Override void addReceiver(AlertNotifyReceiver receiver); @Override void removeReceiver(AlertNotifyReceiver receiver); @Override Optional<Alert> getAlert(Alert.ID id); @Override Optional<Alert> getAlertAsServiceAccount(Alert.ID id); @Override AlertCriteria criteria(); @Override Alert.ID resolve(Serializable ser); @Override Iterator<Alert> getAlerts(AlertCriteria criteria); @Override Iterator<AlertSummary> getAlertsSummary(AlertCriteria criteria); @Override Alert create(URI type,String subtype, Alert.Level level, String description, C content); @Override Alert createEntityAlert(URI type, Alert.Level level, String description, EntityIdentificationAlertContent<C> content); @Override AlertResponse getResponse(Alert alert); @Override Alert remove(Alert.ID id); @Override Long getLastUpdatedTime(); @Override EntityIdentificationAlertContent createEntityIdentificationAlertContent(String entityId, SecurityRole.ENTITY_TYPE entityType, C content); static final int MAX_ALERTS; }### Answer:
@Test public void testGetAlerts() throws InterruptedException { this.manager.create(URI.create("urn:alert:test1"), "subtype",Alert.Level.INFO, "test1", "content"); Thread.sleep(25); this.manager.create(URI.create("urn:alert:test2"), "subtype",Alert.Level.CRITICAL, "test2", "content"); Iterator<? extends Alert> itr = this.manager.getAlerts(null); assertThat(itr.hasNext()).isTrue(); assertThat(itr.next().getLevel()).isEqualTo(Level.INFO); assertThat(itr.hasNext()).isTrue(); assertThat(itr.next().getLevel()).isEqualTo(Level.CRITICAL); assertThat(itr.hasNext()).isFalse(); }