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());
}
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;
}
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());
}
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());
}
Aggregations