Search in sources :

Example 56 with StringValue

use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.

the class ProcessManagerShould method throw_exception_if_dispatch_unknown_event.

@Test(expected = IllegalStateException.class)
public void throw_exception_if_dispatch_unknown_event() {
    final StringValue unknownEvent = StringValue.getDefaultInstance();
    final EventEnvelope envelope = EventEnvelope.of(eventFactory.createEvent(unknownEvent));
    dispatch(processManager, envelope);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 57 with StringValue

use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.

the class ProcessManagerShould method create_iterating_router.

@Test
public void create_iterating_router() {
    final StringValue commandMessage = toMessage("create_iterating_router");
    final CommandContext commandContext = requestFactory.createCommandContext();
    processManager.injectCommandBus(mock(CommandBus.class));
    final IteratingCommandRouter router = processManager.newIteratingRouterFor(commandMessage, commandContext);
    assertNotNull(router);
    assertEquals(commandMessage, getMessage(router.getSource()));
    assertEquals(commandContext, router.getSource().getContext());
}
Also used : CommandContext(io.spine.core.CommandContext) CommandBus(io.spine.server.commandbus.CommandBus) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 58 with StringValue

use of com.google.protobuf.StringValue 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 59 with StringValue

use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.

the class EventsShould method get_producer_from_event_context.

@Test
public void get_producer_from_event_context() {
    final StringValue msg = unpack(context.getProducerId());
    final String id = getProducer(context);
    assertEquals(msg.getValue(), id);
}
Also used : StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 60 with StringValue

use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.

the class EventsShould method setUp.

@Before
public void setUp() {
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    final CommandEnvelope cmd = requestFactory.generateEnvelope();
    final StringValue producerId = toMessage(getClass().getSimpleName());
    EventFactory eventFactory = EventFactory.on(cmd, Identifier.pack(producerId));
    event = eventFactory.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    context = event.getContext();
}
Also used : TestActorRequestFactory(io.spine.client.TestActorRequestFactory) EventFactory(io.spine.server.event.EventFactory) StringValue(com.google.protobuf.StringValue) Before(org.junit.Before)

Aggregations

StringValue (com.google.protobuf.StringValue)75 Test (org.junit.Test)65 Timestamp (com.google.protobuf.Timestamp)8 Command (io.spine.base.Command)5 Command (io.spine.core.Command)5 Any (com.google.protobuf.Any)4 BoolValue (com.google.protobuf.BoolValue)4 Identifiers.idToString (io.spine.base.Identifiers.idToString)4 CommandContext (io.spine.core.CommandContext)4 Event (io.spine.core.Event)4 Wrapper.forString (io.spine.protobuf.Wrapper.forString)4 CommandBus (io.spine.server.commandbus.CommandBus)4 EventFactory (io.spine.server.event.EventFactory)4 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)4 Before (org.junit.Before)4 Optional (com.google.common.base.Optional)3 Message (com.google.protobuf.Message)3 Event (io.spine.base.Event)3 TestActorRequestFactory (io.spine.client.TestActorRequestFactory)3 CommandEnvelope (io.spine.core.CommandEnvelope)3