Search in sources :

Example 16 with Command

use of io.spine.core.Command 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 17 with Command

use of io.spine.core.Command 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 18 with Command

use of io.spine.core.Command 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 19 with Command

use of io.spine.core.Command 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)

Example 20 with Command

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

the class IntegrationBusTestEnv method cannotStartArchivedProject.

// used to create a rejection
@SuppressWarnings("ThrowableNotThrown")
public static Rejection cannotStartArchivedProject() {
    final ProjectId projectId = projectId();
    final ItgStartProject cmdMessage = ItgStartProject.newBuilder().setProjectId(projectId).build();
    final Command startProjectCmd = toCommand(cmdMessage);
    final io.spine.test.integration.rejection.ItgCannotStartArchivedProject throwable = new io.spine.test.integration.rejection.ItgCannotStartArchivedProject(projectId);
    throwable.initProducer(AnyPacker.pack(projectId));
    final Rejection rejection = toRejection(throwable, startProjectCmd);
    return rejection;
}
Also used : Rejections.toRejection(io.spine.core.Rejections.toRejection) Rejection(io.spine.core.Rejection) ItgStartProject(io.spine.test.integration.command.ItgStartProject) Command(io.spine.core.Command) ProjectId(io.spine.test.integration.ProjectId) ItgCannotStartArchivedProject(io.spine.test.integration.rejection.IntegrationRejections.ItgCannotStartArchivedProject)

Aggregations

Command (io.spine.core.Command)137 Test (org.junit.Test)87 Event (io.spine.core.Event)19 TenantId (io.spine.core.TenantId)17 Ack (io.spine.core.Ack)15 Message (com.google.protobuf.Message)14 Rejection (io.spine.core.Rejection)13 CommandEnvelope (io.spine.core.CommandEnvelope)11 Timestamp (com.google.protobuf.Timestamp)9 Error (io.spine.base.Error)9 CommandContext (io.spine.core.CommandContext)9 AggregateMessageDispatcher.dispatchCommand (io.spine.server.aggregate.AggregateMessageDispatcher.dispatchCommand)8 CommandRecord (io.spine.server.commandbus.CommandRecord)8 ProjectId (io.spine.test.aggregate.ProjectId)8 CommandBus (io.spine.server.commandbus.CommandBus)7 GivenEvent (io.spine.server.event.given.EventBusTestEnv.GivenEvent)7 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)7 Any (com.google.protobuf.Any)6 CommandId (io.spine.core.CommandId)6 AggregateTestEnv.newTenantId (io.spine.server.aggregate.given.aggregate.AggregateTestEnv.newTenantId)6