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));
}
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());
}
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);
}
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} — a Json form;
* <li>for {@code String}, {@code Long}, {@code Integer} —
* the result of {@link Object#toString()};
* <li>for {@code null} ID — the {@link #NULL_ID};
* <li>if the result is empty or blank string — 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;
}
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"));
}
Aggregations