use of io.spine.test.event.EBTaskAdded in project core-java by SpineEventEngine.
the class EventBusShould method store_only_events_passing_filters.
/**
* Ensures that events which pass filters and the ones that don’t are treated independently when
* sent in batch.
*
* <p> To filter the {@link EBTaskAdded} events the {@linkplain EventBus} has a custom filter.
* The {@link TaskCreatedFilter} filters out {@link EBTaskAdded} events with
* {@link Task#getDone()} set to {@code true}.
*
* <p> The {@link EBTaskAddedNoOpSubscriber} is registered so that the event would not get
* filtered out by the {@link io.spine.server.bus.DeadMessageFilter}.
*/
@Test
public void store_only_events_passing_filters() {
eventBus.register(new EBTaskAddedNoOpSubscriber());
final Command command = command(addTasks(newTask(false), newTask(true), newTask(false), newTask(true), newTask(true)));
commandBus.post(command, StreamObservers.<Ack>noOpObserver());
final List<Event> storedEvents = readEvents(eventBus);
assertSize(2, storedEvents);
for (Event event : storedEvents) {
final EBTaskAdded contents = unpack(event.getMessage());
final Task task = contents.getTask();
assertFalse(task.getDone());
}
}
Aggregations