use of io.spine.core.Event in project core-java by SpineEventEngine.
the class AggregateMessageDeliveryTestEnv method projectStarted.
public static Event projectStarted() {
final ProjectId projectId = projectId();
final TestEventFactory eventFactory = TestEventFactory.newInstance(pack(projectId), AggregateMessageDeliveryTestEnv.class);
final AggProjectStarted msg = AggProjectStarted.newBuilder().setProjectId(projectId).build();
final Event result = eventFactory.createEvent(msg);
return result;
}
use of io.spine.core.Event in project core-java by SpineEventEngine.
the class EventBusShould method not_store_an_invalid_dead_event.
@Test
public void not_store_an_invalid_dead_event() {
final Command command = command(invalidArchiveProject());
commandBus.post(command, StreamObservers.<Ack>noOpObserver());
final List<Event> events = readEvents(eventBus);
assertSize(0, events);
}
use of io.spine.core.Event in project core-java by SpineEventEngine.
the class EventBusShould method not_call_dispatchers_if_dispatcher_event_execution_postponed.
@Test
public void not_call_dispatchers_if_dispatcher_event_execution_postponed() {
final BareDispatcher dispatcher = new BareDispatcher();
eventBusWithPosponedExecution.register(dispatcher);
final Event event = GivenEvent.projectCreated();
eventBusWithPosponedExecution.post(event);
assertFalse(dispatcher.isDispatchCalled());
final boolean eventPostponed = postponedDispatcherDelivery.isPostponed(event, dispatcher);
assertTrue(eventPostponed);
}
use of io.spine.core.Event in project core-java by SpineEventEngine.
the class EventBusShould method not_store_any_events_when_they_are_failing_filtering.
/**
* Ensures that events are not stored when none of them pass the filters.
*
* <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 not_store_any_events_when_they_are_failing_filtering() {
eventBus.register(new EBTaskAddedNoOpSubscriber());
final Command command = command(addTasks(newTask(true), newTask(true), newTask(true)));
commandBus.post(command, StreamObservers.<Ack>noOpObserver());
final List<Event> storedEvents = readEvents(eventBus);
assertSize(0, storedEvents);
}
use of io.spine.core.Event in project core-java by SpineEventEngine.
the class EventBusShould method call_subscriber_when_event_posted.
@Test
public void call_subscriber_when_event_posted() {
final ProjectCreatedSubscriber subscriber = new ProjectCreatedSubscriber();
final Event event = GivenEvent.projectCreated();
eventBus.register(subscriber);
eventBus.post(event);
// Exclude event ID from comparison.
assertEquals(Events.getMessage(event), subscriber.getEventMessage());
assertEquals(event.getContext(), subscriber.getEventContext());
}
Aggregations