Search in sources :

Example 11 with StringValue

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

the class IdentifiersShould method return_same_string_when_convert_string_wrapped_into_message.

@Test
public void return_same_string_when_convert_string_wrapped_into_message() {
    final StringValue id = forString(TEST_ID);
    final String result = idToString(id);
    assertEquals(TEST_ID, result);
}
Also used : Identifiers.idToString(io.spine.base.Identifiers.idToString) Wrapper.forString(io.spine.protobuf.Wrapper.forString) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 12 with StringValue

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

the class IdentifiersShould method convert_to_string_message_id_wrapped_in_Any.

@Test
public void convert_to_string_message_id_wrapped_in_Any() {
    final StringValue messageToWrap = forString(TEST_ID);
    final Any any = AnyPacker.pack(messageToWrap);
    final String result = idToString(any);
    assertEquals(TEST_ID, result);
}
Also used : Identifiers.idToString(io.spine.base.Identifiers.idToString) Wrapper.forString(io.spine.protobuf.Wrapper.forString) StringValue(com.google.protobuf.StringValue) Identifiers.idToAny(io.spine.base.Identifiers.idToAny) Any(com.google.protobuf.Any) Test(org.junit.Test)

Example 13 with StringValue

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

the class IdentifiersShould method convert_to_string_message_id_with_string_field.

@Test
public void convert_to_string_message_id_with_string_field() {
    final StringValue id = forString(TEST_ID);
    final String result = idToString(id);
    assertEquals(TEST_ID, result);
}
Also used : Identifiers.idToString(io.spine.base.Identifiers.idToString) Wrapper.forString(io.spine.protobuf.Wrapper.forString) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 14 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<String>() {

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

        @Override
        public String dispatch(CommandEnvelope envelope) {
            // Do nothing.
            return "Anonymous";
        }

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

Example 15 with StringValue

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

the class CommandRouterOnErrorShould method throw_IllegalStateException_when_caught_error_when_posting.

@Test(expected = IllegalStateException.class)
public void throw_IllegalStateException_when_caught_error_when_posting() {
    final BoundedContext boundedContext = BoundedContext.newBuilder().build();
    final CommandBus commandBus = boundedContext.getCommandBus();
    // Register dispatcher for `StringValue` message type.
    // Fails each time of dispatch().
    commandBus.register(new CommandDispatcher<Message>() {

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

        @Override
        public Message dispatch(CommandEnvelope envelope) {
            throw new IllegalStateException("I am faulty!");
        }

        @Override
        public void onError(CommandEnvelope envelope, RuntimeException exception) {
        // Do nothing.
        }
    });
    final StringValue sourceMessage = toMessage(getClass().getSimpleName());
    final CommandContext sourceContext = getRequestFactory().createCommandContext();
    final CommandRouter router = createRouter(commandBus, sourceMessage, sourceContext);
    router.addAll(getMessages());
    router.routeAll();
}
Also used : Set(java.util.Set) Message(com.google.protobuf.Message) TypeConverter.toMessage(io.spine.protobuf.TypeConverter.toMessage) CommandContext(io.spine.core.CommandContext) CommandEnvelope(io.spine.core.CommandEnvelope) BoundedContext(io.spine.server.BoundedContext) CommandBus(io.spine.server.commandbus.CommandBus) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

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