Search in sources :

Example 16 with Message

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

the class CommandTestShould method create_different_command.

@Test
public void create_different_command() {
    final Message anotherCommandMsg = Time.getCurrentTime();
    final Command anotherCommand = commandTest.createDifferentCommand(anotherCommandMsg);
    assertEquals(anotherCommandMsg, Commands.getMessage(anotherCommand));
}
Also used : Message(com.google.protobuf.Message) Command(io.spine.base.Command) Test(org.junit.Test)

Example 17 with Message

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

the class CommandTestShould method create_different_command_with_timestamp.

@Test
public void create_different_command_with_timestamp() {
    final Message anotherCommandMsg = Time.getCurrentTime();
    final Timestamp timestamp = TimeTests.Past.minutesAgo(30);
    final Command anotherCommand = commandTest.createDifferentCommand(anotherCommandMsg, timestamp);
    assertEquals(anotherCommandMsg, Commands.getMessage(anotherCommand));
    assertEquals(timestamp, anotherCommand.getContext().getActorContext().getTimestamp());
}
Also used : Message(com.google.protobuf.Message) Command(io.spine.base.Command) Timestamp(com.google.protobuf.Timestamp) Test(org.junit.Test)

Example 18 with Message

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

the class AggregateRootShould method return_part_state_by_class.

@Test
public void return_part_state_by_class() {
    final Message definitionPart = aggregateRoot.getPartState(ProjectDefinition.class);
    assertNotNull(definitionPart);
    final Message lifeCyclePart = aggregateRoot.getPartState(ProjectLifecycle.class);
    assertNotNull(lifeCyclePart);
}
Also used : Message(com.google.protobuf.Message) Test(org.junit.Test)

Example 19 with Message

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

the class Identifiers method idToString.

/**
     * Converts the passed ID value into the string representation.
     *
     * @param id  the value to convert
     * @param <I> the type of the ID
     * @return <ul>
     *              <li>for classes implementing {@link Message} &mdash; a Json form;
     *              <li>for {@code String}, {@code Long}, {@code Integer} &mdash;
     *              the result of {@link Object#toString()};
     *              <li>for {@code null} ID &mdash; the {@link #NULL_ID};
     *              <li>if the result is empty or blank string &mdash; the {@link #EMPTY_ID}.
     *         </ul>
     * @throws IllegalArgumentException if the passed type isn't one of the above or
     *                                  the passed {@link Message} instance has no fields
     * @see StringifierRegistry
     */
public static <I> String idToString(@Nullable I id) {
    if (id == null) {
        return NULL_ID;
    }
    final Identifier<?> identifier;
    if (id instanceof Any) {
        final Message unpacked = unpack((Any) id);
        identifier = Identifier.fromMessage(unpacked);
    } else {
        identifier = Identifier.from(id);
    }
    final String result = identifier.toString();
    return result;
}
Also used : Message(com.google.protobuf.Message) TextFormat.shortDebugString(com.google.protobuf.TextFormat.shortDebugString) Any(com.google.protobuf.Any)

Example 20 with Message

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

the class ValidateShould method return_default_value_on_check.

@Test
public void return_default_value_on_check() {
    final Message defaultValue = StringValue.getDefaultInstance();
    assertEquals(defaultValue, checkDefault(defaultValue));
    assertEquals(defaultValue, checkDefault(defaultValue, "error message"));
}
Also used : Message(com.google.protobuf.Message) Test(org.junit.Test)

Aggregations

Message (com.google.protobuf.Message)266 Test (org.junit.Test)84 Any (com.google.protobuf.Any)30 ByteString (com.google.protobuf.ByteString)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)15 Command (io.spine.core.Command)14 DynamicMessage (com.google.protobuf.DynamicMessage)13 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)10 EntityRecord (io.spine.server.entity.EntityRecord)10 Test (org.junit.jupiter.api.Test)9 HeronTuples (com.twitter.heron.proto.system.HeronTuples)8 Event (io.spine.core.Event)8 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 Method (java.lang.reflect.Method)8 Event (io.spine.base.Event)7 MockHttpInputMessage (org.springframework.http.MockHttpInputMessage)7 MockHttpOutputMessage (org.springframework.http.MockHttpOutputMessage)7 Descriptor (com.google.protobuf.Descriptors.Descriptor)6 Builder (com.google.protobuf.Message.Builder)5