Search in sources :

Example 11 with TestEventFactory

use of io.spine.server.command.TestEventFactory in project core-java by SpineEventEngine.

the class AggregateMessageDeliveryTestEnv method projectStarted.

public static Event projectStarted() {
    final ProjectId projectId = projectId();
    final TestEventFactory eventFactory = TestEventFactory.newInstance(pack(projectId), AggregateMessageDeliveryTestEnv.class);
    final AggProjectStarted msg = AggProjectStarted.newBuilder().setProjectId(projectId).build();
    final Event result = eventFactory.createEvent(msg);
    return result;
}
Also used : TestEventFactory(io.spine.server.command.TestEventFactory) ProjectId(io.spine.test.aggregate.ProjectId) Event(io.spine.core.Event) AggProjectStarted(io.spine.test.aggregate.event.AggProjectStarted)

Example 12 with TestEventFactory

use of io.spine.server.command.TestEventFactory in project core-java by SpineEventEngine.

the class IntegrationBusTestEnv method projectCreated.

public static Event projectCreated() {
    final ProjectId projectId = projectId();
    final TestEventFactory eventFactory = newInstance(pack(projectId), IntegrationBusTestEnv.class);
    return eventFactory.createEvent(ItgProjectCreated.newBuilder().setProjectId(projectId).build());
}
Also used : TestEventFactory(io.spine.server.command.TestEventFactory) ProjectId(io.spine.test.integration.ProjectId)

Example 13 with TestEventFactory

use of io.spine.server.command.TestEventFactory in project core-java by SpineEventEngine.

the class PmMessageDeliveryTestEnv method projectStarted.

public static Event projectStarted() {
    final ProjectId projectId = projectId();
    final TestEventFactory eventFactory = TestEventFactory.newInstance(AnyPacker.pack(projectId), PmMessageDeliveryTestEnv.class);
    final PmProjectStarted msg = PmProjectStarted.newBuilder().setProjectId(projectId).build();
    final Event result = eventFactory.createEvent(msg);
    return result;
}
Also used : TestEventFactory(io.spine.server.command.TestEventFactory) ProjectId(io.spine.test.procman.ProjectId) Event(io.spine.core.Event) PmProjectStarted(io.spine.test.procman.event.PmProjectStarted)

Example 14 with TestEventFactory

use of io.spine.server.command.TestEventFactory in project core-java by SpineEventEngine.

the class ProjectionShould method expose_playing_events_to_the_package.

@Test
public void expose_playing_events_to_the_package() {
    final TestEventFactory eventFactory = TestEventFactory.newInstance(getClass());
    final StringValue strValue = StringValue.newBuilder().setValue("eins zwei drei").build();
    final Int32Value intValue = Int32Value.newBuilder().setValue(123).build();
    final Version nextVersion = Versions.increment(projection.getVersion());
    final Event e1 = eventFactory.createEvent(strValue, nextVersion);
    final Event e2 = eventFactory.createEvent(intValue, Versions.increment(nextVersion));
    final boolean projectionChanged = Projection.play(projection, ImmutableList.of(e1, e2));
    final String projectionState = projection.getState().getValue();
    assertTrue(projectionChanged);
    assertTrue(projectionState.contains(strValue.getValue()));
    assertTrue(projectionState.contains(String.valueOf(intValue.getValue())));
}
Also used : TestEventFactory(io.spine.server.command.TestEventFactory) Version(io.spine.core.Version) Int32Value(com.google.protobuf.Int32Value) Event(io.spine.core.Event) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 15 with TestEventFactory

use of io.spine.server.command.TestEventFactory in project core-java by SpineEventEngine.

the class AggregateMessageDispatcherShould method dispatch_event.

@Test
public void dispatch_event() {
    final TestEventFactory factory = TestEventFactory.newInstance(getClass());
    final float messageValue = 2017.0729f;
    final FloatValue message = FloatValue.newBuilder().setValue(messageValue).build();
    final EventEnvelope eventEnvelope = EventEnvelope.of(factory.createEvent(message));
    final List<? extends Message> eventMessages = dispatchEvent(aggregate, eventEnvelope);
    assertTrue(aggregate.getState().getValue().contains(String.valueOf(messageValue)));
    assertEquals(1, eventMessages.size());
    assertTrue(eventMessages.get(0) instanceof StringValue);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) TestEventFactory(io.spine.server.command.TestEventFactory) FloatValue(com.google.protobuf.FloatValue) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Aggregations

TestEventFactory (io.spine.server.command.TestEventFactory)16 Event (io.spine.core.Event)10 Test (org.junit.Test)8 EventEnvelope (io.spine.core.EventEnvelope)4 StringValue (com.google.protobuf.StringValue)3 ProjectId (io.spine.test.aggregate.ProjectId)2 AggProjectArchived (io.spine.test.aggregate.event.AggProjectArchived)2 ProjectId (io.spine.test.integration.ProjectId)2 NullPointerTester (com.google.common.testing.NullPointerTester)1 Duration (com.google.protobuf.Duration)1 FloatValue (com.google.protobuf.FloatValue)1 Int32Value (com.google.protobuf.Int32Value)1 Timestamp (com.google.protobuf.Timestamp)1 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)1 Command (io.spine.core.Command)1 MessageEnvelope (io.spine.core.MessageEnvelope)1 Version (io.spine.core.Version)1 GivenEvent (io.spine.core.given.GivenEvent)1 AggregateEventRecord (io.spine.server.aggregate.AggregateEventRecord)1 FailingAggregateRepository (io.spine.server.aggregate.given.AggregateRepositoryTestEnv.FailingAggregateRepository)1