@Test @DisplayName("filter out non-allowed events") void filterOut() { List<Event> events = Stream.<EventMessage>of(EntProjectStarted.getDefaultInstance(), EntTaskAdded.getDefaultInstance()) .map(eventFactory::createEvent) .collect(toList()); Collection<Event> filtered = whiteList.filter(events); assertEquals(1, filtered.size()); assertTrue(events.contains(events.get(0))); }
@Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return allowedEvents.contains(type) ? Optional.of(event) : Optional.empty(); }
EventWhiteList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return allowedEvents.contains(type) ? Optional.of(event) : Optional.empty(); } }
EventWhiteList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return allowedEvents.contains(type) ? Optional.of(event) : Optional.empty(); } private  EventWhiteList(ImmutableSet<EventClass> allowedEvents); }
EventWhiteList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return allowedEvents.contains(type) ? Optional.of(event) : Optional.empty(); } private  EventWhiteList(ImmutableSet<EventClass> allowedEvents); @SuppressWarnings("WeakerAccess") // Public API of the framework. @SafeVarargs static EventWhiteList allowEvents(Class<? extends EventMessage>... eventClasses); @Override Optional<? extends EventMessage> filter(EventMessage event); }
EventWhiteList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return allowedEvents.contains(type) ? Optional.of(event) : Optional.empty(); } private  EventWhiteList(ImmutableSet<EventClass> allowedEvents); @SuppressWarnings("WeakerAccess") // Public API of the framework. @SafeVarargs static EventWhiteList allowEvents(Class<? extends EventMessage>... eventClasses); @Override Optional<? extends EventMessage> filter(EventMessage event);  }