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));
}
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();
}
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;
}
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();
}
Aggregations