Search in sources :

Example 1 with StringValue

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

the class TypeNameShould method obtain_type_name_of_event.

@Test
public void obtain_type_name_of_event() {
    final Command command = requestFactory.command().create(newUuidValue());
    final StringValue producerId = Wrapper.forString(getClass().getSimpleName());
    final EventFactory ef = EventFactory.newBuilder().setCommandId(Commands.generateId()).setProducerId(producerId).setCommandContext(command.getContext()).build();
    final Event event = ef.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    final TypeName typeName = TypeName.ofEvent(event);
    assertNotNull(typeName);
    assertEquals(Timestamp.class.getSimpleName(), typeName.getSimpleName());
}
Also used : Command(io.spine.base.Command) EventFactory(io.spine.server.command.EventFactory) Event(io.spine.base.Event) StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 2 with StringValue

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

the class ProcessManagerShould method create_router.

@Test
public void create_router() {
    final StringValue commandMessage = Wrapper.forString("create_router");
    final CommandContext commandContext = requestFactory.createCommandContext();
    processManager.setCommandBus(mock(CommandBus.class));
    final CommandRouter router = processManager.newRouterFor(commandMessage, commandContext);
    assertNotNull(router);
    assertEquals(commandMessage, getMessage(router.getSource()));
    assertEquals(commandContext, router.getSource().getContext());
}
Also used : CommandContext(io.spine.base.CommandContext) CommandBus(io.spine.server.commandbus.CommandBus) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 3 with StringValue

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

the class AbstractCommandRouterShould method setUp.

@Before
public void setUp() {
    final BoundedContext boundedContext = BoundedContext.newBuilder().build();
    final CommandBus commandBus = boundedContext.getCommandBus();
    // Register dispatcher for `StringValue` message type.
    // Otherwise we won't be able to post.
    commandBus.register(new CommandDispatcher() {

        @Override
        public Set<CommandClass> getMessageClasses() {
            return CommandClass.setOf(StringValue.class);
        }

        @Override
        public void dispatch(CommandEnvelope envelope) {
        // Do nothing.
        }
    });
    sourceMessage = Wrapper.forString(getClass().getSimpleName());
    sourceContext = requestFactory.createCommandContext();
    router = createRouter(commandBus, sourceMessage, sourceContext);
    router.addAll(messages);
}
Also used : Set(java.util.Set) CommandDispatcher(io.spine.server.commandbus.CommandDispatcher) CommandEnvelope(io.spine.envelope.CommandEnvelope) BoundedContext(io.spine.server.BoundedContext) CommandBus(io.spine.server.commandbus.CommandBus) StringValue(com.google.protobuf.StringValue) Before(org.junit.Before)

Example 4 with StringValue

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

the class QueryParameterShould method support_equality.

@Test
public void support_equality() {
    final String param1 = "param1";
    final String param2 = "param2";
    final String foobar = "foobar";
    final String baz = "baz";
    final StringValue foobarValue = StringValue.newBuilder().setValue(foobar).build();
    final QueryParameter parameter1 = eq(param1, foobar);
    final QueryParameter parameter2 = eq(param1, foobarValue);
    final QueryParameter parameter3 = eq(param1, baz);
    final QueryParameter parameter4 = eq(param2, foobar);
    new EqualsTester().addEqualityGroup(parameter1, parameter2).addEqualityGroup(parameter3).addEqualityGroup(parameter4).testEquals();
}
Also used : QueryParameter(io.spine.client.QueryParameter) EqualsTester(com.google.common.testing.EqualsTester) String(java.lang.String) Matchers.containsString(org.hamcrest.Matchers.containsString) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 5 with StringValue

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

the class ValidateShould method check_a_message_is_default_with_parametrized_error_message.

@Test(expected = IllegalStateException.class)
public void check_a_message_is_default_with_parametrized_error_message() {
    final StringValue nonDefault = newUuidValue();
    checkDefault(nonDefault, "Message value: %s, Type name: %s", nonDefault, TypeName.of(nonDefault));
}
Also used : StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Aggregations

StringValue (com.google.protobuf.StringValue)47 Test (org.junit.Test)41 Command (io.spine.base.Command)7 Timestamp (com.google.protobuf.Timestamp)5 Any (com.google.protobuf.Any)4 Event (io.spine.base.Event)4 Identifiers.idToString (io.spine.base.Identifiers.idToString)4 Wrapper.forString (io.spine.protobuf.Wrapper.forString)4 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)4 CommandContext (io.spine.base.CommandContext)3 EventFactory (io.spine.server.command.EventFactory)3 CommandBus (io.spine.server.commandbus.CommandBus)3 Version (io.spine.base.Version)2 EntityStateEnvelope (io.spine.server.entity.EntityStateEnvelope)2 TestActorRequestFactory (io.spine.test.TestActorRequestFactory)2 Before (org.junit.Before)2 EqualsTester (com.google.common.testing.EqualsTester)1 FieldMask (com.google.protobuf.FieldMask)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Message (com.google.protobuf.Message)1