use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.
the class BoundedContextShould method notify_integration_event_subscriber.
@Test
public void notify_integration_event_subscriber() {
registerAll();
final MemoizingObserver<Ack> observer = memoizingObserver();
final IntegrationEvent event = Given.AnIntegrationEvent.projectCreated();
final Message msg = unpack(event.getMessage());
boundedContext.notify(event, observer);
assertEquals(Responses.statusOk(), observer.firstResponse().getStatus());
assertEquals(subscriber.getHandledEvent(), msg);
}
use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.
the class BoundedContext method notify.
/**
* Sends an integration event to this {@code BoundedContext}.
*/
@Experimental
@Override
public void notify(IntegrationEvent integrationEvent, StreamObserver<Ack> observer) {
final Event event = EventFactory.toEvent(integrationEvent);
eventBus.post(event, observer);
}
use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.
the class EventFactory method toEvent.
/**
* Creates an event based on the passed integration event.
*/
public static Event toEvent(IntegrationEvent integrationEvent) {
final IntegrationEventContext sourceContext = integrationEvent.getContext();
final EventContext context = toEventContext(sourceContext);
final Event result = createEvent(sourceContext.getEventId(), integrationEvent.getMessage(), context);
return result;
}
use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.
the class EventFactory method toEvent.
/**
* Creates an event based on the passed integration event.
*/
public static Event toEvent(IntegrationEvent integrationEvent) {
final IntegrationEventContext sourceContext = integrationEvent.getContext();
final EventContext context = toEventContext(sourceContext);
final Event result = createEvent(sourceContext.getEventId(), integrationEvent.getMessage(), context);
return result;
}
use of io.spine.server.integration.IntegrationEvent in project core-java by SpineEventEngine.
the class BoundedContext method notify.
@SuppressWarnings("MethodDoesntCallSuperMethod")
/* We ignore method from super because the default implementation sets
unimplemented status. */
@Override
public void notify(IntegrationEvent integrationEvent, StreamObserver<Response> responseObserver) {
final Message eventMsg = unpack(integrationEvent.getMessage());
final boolean isValid = eventBus.validate(eventMsg, responseObserver);
if (isValid) {
final Event event = EventFactory.toEvent(integrationEvent);
eventBus.post(event);
}
}
Aggregations