@Test @DisplayName("allow events of type not from the list") void allowArbitrary() { EventMessage event = EntProjectCreated.getDefaultInstance(); Optional<? extends EventMessage> filtered = blackList.filter(event); assertTrue(filtered.isPresent()); assertEquals(event, filtered.get()); }
@Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return forbiddenEvents.contains(type) ? Optional.empty() : Optional.of(event); }
EventBlackList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return forbiddenEvents.contains(type) ? Optional.empty() : Optional.of(event); } }
EventBlackList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return forbiddenEvents.contains(type) ? Optional.empty() : Optional.of(event); } private  EventBlackList(ImmutableSet<EventClass> forbiddenEvents); }
EventBlackList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return forbiddenEvents.contains(type) ? Optional.empty() : Optional.of(event); } private  EventBlackList(ImmutableSet<EventClass> forbiddenEvents); @SafeVarargs static EventBlackList discardEvents(Class<? extends EventMessage>... eventClasses); @Override Optional<? extends EventMessage> filter(EventMessage event); }
EventBlackList implements EventFilter { @Override public Optional<? extends EventMessage> filter(EventMessage event) { EventClass type = EventClass.of(event); return forbiddenEvents.contains(type) ? Optional.empty() : Optional.of(event); } private  EventBlackList(ImmutableSet<EventClass> forbiddenEvents); @SafeVarargs static EventBlackList discardEvents(Class<? extends EventMessage>... eventClasses); @Override Optional<? extends EventMessage> filter(EventMessage event);  }