Search in sources :

Example 1 with CreateProject

use of io.spine.test.aggregate.command.CreateProject in project core-java by SpineEventEngine.

the class AggregateCommandEndpointShould method store_aggregate_on_command_dispatching.

@Test
public void store_aggregate_on_command_dispatching() {
    final CommandEnvelope cmd = CommandEnvelope.of(createProject(projectId));
    final CreateProject msg = (CreateProject) cmd.getMessage();
    repositorySpy.dispatch(cmd);
    final ProjectAggregate aggregate = verifyAggregateStored(repositorySpy);
    assertEquals(projectId, aggregate.getId());
    assertEquals(msg.getName(), aggregate.getState().getName());
}
Also used : CommandEnvelope(io.spine.envelope.CommandEnvelope) CreateProject(io.spine.test.aggregate.command.CreateProject) Test(org.junit.Test)

Example 2 with CreateProject

use of io.spine.test.aggregate.command.CreateProject in project core-java by SpineEventEngine.

the class AggregateRepositoryShould method givenAggregateWithUncommittedEvents.

private static ProjectAggregate givenAggregateWithUncommittedEvents(ProjectId id) {
    final ProjectAggregate aggregate = Given.aggregateOfClass(ProjectAggregate.class).withId(id).build();
    final CreateProject createProject = ((CreateProject.Builder) Sample.builderForType(CreateProject.class)).setProjectId(id).build();
    final AddTask addTask = ((AddTask.Builder) Sample.builderForType(AddTask.class)).setProjectId(id).build();
    final StartProject startProject = ((StartProject.Builder) Sample.builderForType(StartProject.class)).setProjectId(id).build();
    dispatch(aggregate, env(createProject));
    dispatch(aggregate, env(addTask));
    dispatch(aggregate, env(startProject));
    return aggregate;
}
Also used : AddTask(io.spine.test.aggregate.command.AddTask) CreateProject(io.spine.test.aggregate.command.CreateProject) StartProject(io.spine.test.aggregate.command.StartProject)

Example 3 with CreateProject

use of io.spine.test.aggregate.command.CreateProject in project core-java by SpineEventEngine.

the class AggregateShould method transform_current_state_to_snapshot_event.

@Test
public void transform_current_state_to_snapshot_event() {
    dispatch(aggregate, env(createProject));
    final Snapshot snapshot = aggregate.toSnapshot();
    final Project state = unpack(snapshot.getState());
    assertEquals(ID, state.getId());
    assertEquals(Status.CREATED, state.getStatus());
}
Also used : CreateProject(io.spine.test.aggregate.command.CreateProject) StartProject(io.spine.test.aggregate.command.StartProject) Project(io.spine.test.aggregate.Project) Test(org.junit.Test)

Example 4 with CreateProject

use of io.spine.test.aggregate.command.CreateProject in project core-java by SpineEventEngine.

the class AggregateShould method update_state_when_the_command_is_handled.

@Test
public void update_state_when_the_command_is_handled() {
    dispatch(aggregate, env(createProject));
    final Project state = aggregate.getState();
    assertEquals(ID, state.getId());
    assertEquals(Status.CREATED, state.getStatus());
}
Also used : CreateProject(io.spine.test.aggregate.command.CreateProject) StartProject(io.spine.test.aggregate.command.StartProject) Project(io.spine.test.aggregate.Project) Test(org.junit.Test)

Aggregations

CreateProject (io.spine.test.aggregate.command.CreateProject)4 StartProject (io.spine.test.aggregate.command.StartProject)3 Test (org.junit.Test)3 Project (io.spine.test.aggregate.Project)2 CommandEnvelope (io.spine.envelope.CommandEnvelope)1 AddTask (io.spine.test.aggregate.command.AddTask)1