Search in sources :

Example 1 with EventEnricher

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);
}
Also used : EventEnricher(io.spine.server.event.enrich.EventEnricher) Test(org.junit.Test)

Example 2 with EventEnricher

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);
}
Also used : EventEnricher(io.spine.server.event.enrich.EventEnricher) Test(org.junit.Test)

Example 3 with EventEnricher

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);
}
Also used : EventEnricher(io.spine.server.event.enrich.EventEnricher) Test(org.junit.Test)

Example 4 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_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);
}
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 5 with EventEnricher

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));
}
Also used : EventEnricher(io.spine.server.event.enrich.EventEnricher) Event(io.spine.base.Event) 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