Search in sources :

Example 1 with ProjectCreated

use of io.spine.test.event.ProjectCreated in project core-java by SpineEventEngine.

the class EnrichmentFunctionShould method apply_enrichment.

@Test
public void apply_enrichment() throws Exception {
    final ProjectCreated event = Given.EventMessage.projectCreated();
    final ProjectCreated.Enrichment enriched = fieldEnricher.apply(event);
    assertNotNull(enriched);
    assertEquals(event.getProjectId().getId(), enriched.getProjectName());
}
Also used : ProjectCreated(io.spine.test.event.ProjectCreated) Test(org.junit.Test)

Example 2 with ProjectCreated

use of io.spine.test.event.ProjectCreated in project core-java by SpineEventEngine.

the class EventEnricherShould method enrich_event_with_several_fields_by_same_source_id.

@Test
public void enrich_event_with_several_fields_by_same_source_id() {
    final ProjectCreated msg = projectCreated();
    final ProjectId projectId = msg.getProjectId();
    eventBus.post(createEvent(msg));
    assertEquals(getProjectName.apply(projectId), subscriber.projectCreatedEnrichment.getProjectName());
    assertEquals(getProjectOwnerId.apply(projectId), subscriber.projectCreatedEnrichment.getOwnerId());
}
Also used : ProjectId(io.spine.test.event.ProjectId) ProjectCreated(io.spine.test.event.ProjectCreated) Test(org.junit.Test)

Example 3 with ProjectCreated

use of io.spine.test.event.ProjectCreated in project core-java by SpineEventEngine.

the class EventEnricherShould method enrich_event_if_function_added_at_runtime.

@Test
public void enrich_event_if_function_added_at_runtime() {
    final GetProjectMaxMemberCount function = new GetProjectMaxMemberCount();
    enricher.registerFieldEnrichment(ProjectId.class, Integer.class, function);
    final ProjectCreated msg = projectCreated();
    final ProjectId projectId = msg.getProjectId();
    eventBus.post(createEvent(msg));
    // the `function` was specially implemented to return non-null ints.
    @SuppressWarnings("ConstantConditions") final int expectedValue = function.apply(projectId);
    assertEquals(expectedValue, subscriber.projectCreatedDynamicEnrichment.getMaxMemberCount());
}
Also used : GetProjectMaxMemberCount(io.spine.server.event.Given.Enrichment.GetProjectMaxMemberCount) ProjectId(io.spine.test.event.ProjectId) ProjectCreated(io.spine.test.event.ProjectCreated) Test(org.junit.Test)

Example 4 with ProjectCreated

use of io.spine.test.event.ProjectCreated in project core-java by SpineEventEngine.

the class EventEnricherShould method enrich_event_if_enrichment_definition_is_not_enclosed_to_event_same_package.

@Test
public void enrich_event_if_enrichment_definition_is_not_enclosed_to_event_same_package() {
    final ProjectCreated msg = projectCreated();
    eventBus.post(createEvent(msg));
    assertEquals(getProjectName.apply(msg.getProjectId()), subscriber.projectCreatedSeparateEnrichment.getProjectName());
}
Also used : ProjectCreated(io.spine.test.event.ProjectCreated) Test(org.junit.Test)

Example 5 with ProjectCreated

use of io.spine.test.event.ProjectCreated in project core-java by SpineEventEngine.

the class EventEnricherShould method enrich_event_if_enrichment_definition_is_in_another_package.

@Test
public void enrich_event_if_enrichment_definition_is_in_another_package() {
    final ProjectCreated msg = projectCreated();
    eventBus.post(createEvent(msg));
    assertEquals(getProjectName.apply(msg.getProjectId()), subscriber.projectCreatedAnotherPackEnrichment.getProjectName());
}
Also used : ProjectCreated(io.spine.test.event.ProjectCreated) Test(org.junit.Test)

Aggregations

ProjectCreated (io.spine.test.event.ProjectCreated)5 Test (org.junit.Test)5 ProjectId (io.spine.test.event.ProjectId)2 GetProjectMaxMemberCount (io.spine.server.event.Given.Enrichment.GetProjectMaxMemberCount)1