Search in sources :

Example 6 with EventEnricher

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_previously_set.

@Test
public void allow_enrichment_configuration_at_runtime_if_enricher_previously_set() {
    final EventEnricher enricher = mock(EventEnricher.class);
    setUp(enricher);
    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);
    verify(enricher).registerFieldEnrichment(eq(eventFieldClass), eq(enrichmentFieldClass), eq(function));
}
Also used : Function(com.google.common.base.Function) EventEnricher(io.spine.server.event.enrich.EventEnricher) ProjectId(io.spine.test.event.ProjectId) Nullable(javax.annotation.Nullable) Test(org.junit.Test)

Example 7 with EventEnricher

use of io.spine.server.event.enrich.EventEnricher in project core-java by SpineEventEngine.

the class EventBusBuilderShould method return_set_Enricher.

@Test
public void return_set_Enricher() {
    final EventEnricher enricher = mock(EventEnricher.class);
    assertEquals(enricher, EventBus.newBuilder().setStorageFactory(storageFactory).setEnricher(enricher).getEnricher().get());
}
Also used : EventEnricher(io.spine.server.event.enrich.EventEnricher) Test(org.junit.Test)

Aggregations

EventEnricher (io.spine.server.event.enrich.EventEnricher)7 Test (org.junit.Test)7 Function (com.google.common.base.Function)2 ProjectId (io.spine.test.event.ProjectId)2 Nullable (javax.annotation.Nullable)2 Event (io.spine.base.Event)1