use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.
the class EventEnricherBuilderShould method build_enricher_if_all_functions_registered.
@Test
public void build_enricher_if_all_functions_registered() {
final EventEnricher enricher = Given.Enrichment.newEventEnricher();
assertNotNull(enricher);
}
use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.
the class EventEnricherBuilderShould method allow_registering_just_some_of_expected_functions.
@Test
public void allow_registering_just_some_of_expected_functions() {
builder.addFieldEnrichment(ProjectId.class, UserId.class, new Given.Enrichment.GetProjectOwnerId());
builder.addFieldEnrichment(ProjectId.class, String.class, new Given.Enrichment.GetProjectName());
final EventEnricher enricher = builder.build();
assertNotNull(enricher);
}
use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.
the class EventEnricherBuilderShould method allow_registering_no_functions.
@Test
public void allow_registering_no_functions() {
final EventEnricher enricher = EventEnricher.newBuilder().build();
assertNotNull(enricher);
}
use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.
the class EventBusShould method allow_enrichment_configuration_at_runtime_if_enricher_not_set_previously.
@Test
public void allow_enrichment_configuration_at_runtime_if_enricher_not_set_previously() {
setUp(null);
assertNull(eventBus.getEnricher());
final Class<ProjectId> eventFieldClass = ProjectId.class;
final Class<String> enrichmentFieldClass = String.class;
final Function<ProjectId, String> function = new Function<ProjectId, String>() {
@Override
public String apply(@Nullable ProjectId input) {
checkNotNull(input);
return input.toString();
}
};
eventBus.addFieldEnrichment(eventFieldClass, enrichmentFieldClass, function);
final EventEnricher enricher = eventBus.getEnricher();
assertNotNull(enricher);
}
use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.
the class EventBusShould method do_not_enrich_event_if_it_cannot_be_enriched.
@Test
public void do_not_enrich_event_if_it_cannot_be_enriched() {
final EventEnricher enricher = mock(EventEnricher.class);
doReturn(false).when(enricher).canBeEnriched(any(Event.class));
setUp(enricher);
eventBus.register(new ProjectCreatedSubscriber());
eventBus.post(Given.AnEvent.projectCreated());
verify(enricher, never()).enrich(any(Event.class));
}