Search in sources :

Example 6 with EventClass

use of io.spine.core.EventClass in project core-java by SpineEventEngine.

the class EventBusShould method register_event_subscriber.

@Test
public void register_event_subscriber() {
    final EventSubscriber subscriberOne = new ProjectCreatedSubscriber();
    final EventSubscriber subscriberTwo = new ProjectCreatedSubscriber();
    eventBus.register(subscriberOne);
    eventBus.register(subscriberTwo);
    final EventClass eventClass = EventClass.of(ProjectCreated.class);
    assertTrue(eventBus.hasDispatchers(eventClass));
    final Collection<? extends EventDispatcher<?>> dispatchers = eventBus.getDispatchers(eventClass);
    assertTrue(dispatchers.contains(subscriberOne));
    assertTrue(dispatchers.contains(subscriberTwo));
}
Also used : EventClass(io.spine.core.EventClass) Test(org.junit.Test)

Example 7 with EventClass

use of io.spine.core.EventClass in project core-java by SpineEventEngine.

the class ProjectionRepository method createEventFilters.

/**
 * Obtains event filters for event classes handled by projections of this repository.
 */
private Set<EventFilter> createEventFilters() {
    final ImmutableSet.Builder<EventFilter> builder = ImmutableSet.builder();
    final Set<EventClass> eventClasses = getMessageClasses();
    for (EventClass eventClass : eventClasses) {
        final String typeName = TypeName.of(eventClass.value()).value();
        builder.add(EventFilter.newBuilder().setEventType(typeName).build());
    }
    return builder.build();
}
Also used : EventClass(io.spine.core.EventClass) ImmutableSet(com.google.common.collect.ImmutableSet) EventFilter(io.spine.server.event.EventFilter)

Example 8 with EventClass

use of io.spine.core.EventClass in project core-java by SpineEventEngine.

the class UnsupportedEventException method messageFormat.

private static String messageFormat(Message eventMsg) {
    final EventClass eventClass = EventClass.of(eventMsg);
    final String typeName = TypeName.of(eventMsg).value();
    final String result = format("There is no registered handler or dispatcher for the event of class: `%s`." + " Protobuf type: `%s`", eventClass, typeName);
    return result;
}
Also used : EventClass(io.spine.core.EventClass)

Example 9 with EventClass

use of io.spine.core.EventClass in project core-java by SpineEventEngine.

the class ExternalMessageClass method fromEventClasses.

/**
 * Transforms a given set of {@linkplain EventClass event classes} into a set
 * of {@code ExternalMessageClass}es by wrapping each event class
 * into an external message class.
 *
 * @param classes the set of event classes to transform
 * @return a set of {@code ExternalMessageClass}es, each wrapping an item from the original set
 */
public static Set<ExternalMessageClass> fromEventClasses(Set<EventClass> classes) {
    checkNotNull(classes);
    final ImmutableSet.Builder<ExternalMessageClass> builder = ImmutableSet.builder();
    for (EventClass eventClass : classes) {
        builder.add(of(eventClass));
    }
    return builder.build();
}
Also used : EventClass(io.spine.core.EventClass) ImmutableSet(com.google.common.collect.ImmutableSet)

Aggregations

EventClass (io.spine.core.EventClass)9 Test (org.junit.Test)4 ImmutableSet (com.google.common.collect.ImmutableSet)2 ExternalMessageClass (io.spine.server.integration.ExternalMessageClass)2 SPI (io.spine.annotation.SPI)1 CommandClass (io.spine.core.CommandClass)1 EventEnvelope (io.spine.core.EventEnvelope)1 RejectionClass (io.spine.core.RejectionClass)1 BoundedContext (io.spine.server.BoundedContext)1 EventFilter (io.spine.server.event.EventFilter)1 ExternalMessageDispatcher (io.spine.server.integration.ExternalMessageDispatcher)1 ExternalMessageEnvelope (io.spine.server.integration.ExternalMessageEnvelope)1