Search in sources :

Example 11 with Event

use of io.spine.core.Event in project core-java by SpineEventEngine.

the class EventEnricherShould method enrich_event_if_enrichment_definition_is_enclosed_to_event.

@Test
public void enrich_event_if_enrichment_definition_is_enclosed_to_event() {
    final ProjectStarted msg = GivenEventMessage.projectStarted();
    final Event event = createEvent(msg);
    eventBus.post(event);
    assertEquals(getProjectName.apply(msg.getProjectId()), subscriber.projectStartedEnrichment.getProjectName());
}
Also used : ProjectStarted(io.spine.test.event.ProjectStarted) Event(io.spine.core.Event) GivenEvent(io.spine.server.event.given.EventEnricherTestEnv.GivenEvent) Test(org.junit.Test)

Example 12 with Event

use of io.spine.core.Event in project core-java by SpineEventEngine.

the class EventRootCommandIdShould method match_the_id_of_a_command_handled_by_an_aggregate.

@Test
public void match_the_id_of_a_command_handled_by_an_aggregate() {
    final Command command = command(createProject(projectId(), teamId()));
    postCommand(command);
    final List<Event> events = readEvents();
    assertEquals(command.getId(), getRootCommandId(events.get(0)));
}
Also used : Command(io.spine.core.Command) Event(io.spine.core.Event) Test(org.junit.Test)

Example 13 with Event

use of io.spine.core.Event in project core-java by SpineEventEngine.

the class EventRootCommandIdShould method match_the_id_of_a_command_handled_by_a_process_manager.

@Test
public void match_the_id_of_a_command_handled_by_a_process_manager() {
    final Command command = command(addTeamMember(teamId()));
    postCommand(command);
    final List<Event> events = readEvents();
    assertSize(1, events);
    final Event event = events.get(0);
    assertEquals(command.getId(), getRootCommandId(event));
}
Also used : Command(io.spine.core.Command) Event(io.spine.core.Event) Test(org.junit.Test)

Example 14 with Event

use of io.spine.core.Event in project core-java by SpineEventEngine.

the class EventRootCommandIdShould method match_the_id_of_a_command_handled_by_a_process_manager_for_multiple_events.

@Test
public void match_the_id_of_a_command_handled_by_a_process_manager_for_multiple_events() {
    final Command command = command(inviteTeamMembers(teamId(), 3));
    postCommand(command);
    final List<Event> events = readEvents();
    assertSize(3, events);
    assertEquals(command.getId(), getRootCommandId(events.get(0)));
    assertEquals(command.getId(), getRootCommandId(events.get(1)));
    assertEquals(command.getId(), getRootCommandId(events.get(2)));
}
Also used : Command(io.spine.core.Command) Event(io.spine.core.Event) Test(org.junit.Test)

Example 15 with Event

use of io.spine.core.Event in project core-java by SpineEventEngine.

the class EventRootCommandIdShould method match_the_id_of_an_external_event_handled_by_a_process_manager.

/**
 * Ensures root command ID is matched by the property of the event which is created as
 * a reaction to another event.
 *
 * <p> Two events are expected to be found in the {@linkplain EventStore} created by different
 * process managers:
 * <ol>
 *     <li>{@link io.spine.server.event.given.EventRootCommandIdTestEnv.UserSignUpProcessManager} —
 *     {@link EvInvitationAccepted}</li>
 *     <li>{@link io.spine.server.event.given.EventRootCommandIdTestEnv.TeamCreationProcessManager} —
 *     {@link EvTeamMemberAdded} created as a reaction to {@link EvInvitationAccepted}</li>
 * </ol>
 */
@Test
public void match_the_id_of_an_external_event_handled_by_a_process_manager() {
    final Command command = command(acceptInvitation(teamId()));
    postCommand(command);
    final List<Event> events = readEvents();
    assertSize(2, events);
    final Event reaction = events.get(1);
    assertEquals(command.getId(), getRootCommandId(reaction));
}
Also used : Command(io.spine.core.Command) Event(io.spine.core.Event) Test(org.junit.Test)

Aggregations

Event (io.spine.core.Event)115 Test (org.junit.Test)75 Command (io.spine.core.Command)19 EventContext (io.spine.core.EventContext)12 BoundedContext (io.spine.server.BoundedContext)12 GivenEvent (io.spine.server.event.given.EventBusTestEnv.GivenEvent)12 Version (io.spine.core.Version)10 TestEventFactory (io.spine.server.command.TestEventFactory)10 Message (com.google.protobuf.Message)9 EventEnvelope (io.spine.core.EventEnvelope)9 InMemoryTransportFactory (io.spine.server.integration.memory.InMemoryTransportFactory)9 Timestamp (com.google.protobuf.Timestamp)6 Ack (io.spine.core.Ack)6 TenantId (io.spine.core.TenantId)6 Error (io.spine.base.Error)5 AggregateMessageDispatcher.dispatchCommand (io.spine.server.aggregate.AggregateMessageDispatcher.dispatchCommand)5 AggregateTestEnv.newTenantId (io.spine.server.aggregate.given.aggregate.AggregateTestEnv.newTenantId)5 StringValue (com.google.protobuf.StringValue)4 GivenEvent (io.spine.core.given.GivenEvent)4 Duration (com.google.protobuf.Duration)3