use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class IteratingCommandRouter method routeNext.
/**
* Creates and posts a next command.
*
* <p>The commands are created and posted in the sequence their messages were added.
*
* @return the posted command
* @throws NoSuchElementException if there are no command messages to post
* @see #hasNext()
*/
protected Command routeNext() {
final Message message = next();
final Command command = route(message);
return command;
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class QueryBuilderShould method create_queries_with_multiple_params.
@Test
public void create_queries_with_multiple_params() {
final String columnName1 = "myColumn";
final Object columnValue1 = 42;
final String columnName2 = "oneMore";
final Object columnValue2 = newMessageId();
final Query query = factory().query().select(TestEntity.class).where(eq(columnName1, columnValue1), eq(columnName2, columnValue2)).build();
assertNotNull(query);
final Target target = query.getTarget();
assertFalse(target.getIncludeAll());
final EntityFilters entityFilters = target.getFilters();
final List<CompositeColumnFilter> aggregatingColumnFilters = entityFilters.getFilterList();
assertSize(1, aggregatingColumnFilters);
final Collection<ColumnFilter> columnFilters = aggregatingColumnFilters.get(0).getFilterList();
final Any actualValue1 = findByName(columnFilters, columnName1).getValue();
assertNotNull(actualValue1);
final int actualGenericValue1 = toObject(actualValue1, int.class);
assertEquals(columnValue1, actualGenericValue1);
final Any actualValue2 = findByName(columnFilters, columnName2).getValue();
assertNotNull(actualValue2);
final Message actualGenericValue2 = toObject(actualValue2, ProjectId.class);
assertEquals(columnValue2, actualGenericValue2);
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class MessageMismatch method unpackActual.
/**
* Obtains actual value as a {@code Message} from the passed mismatch.
*
* @throws RuntimeException if the passed instance represent a mismatch of
* non-{@code Message} values
*/
public static Message unpackActual(ValueMismatch mismatch) {
checkNotNull(mismatch);
final Any any = mismatch.getActual();
final Message result = unpack(any);
return result;
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class MessageMismatch method expectedDefault.
/**
* Creates {@code ValueMismatch} for the case of discovering a non-default value,
* when the default value was expected by a command.
*
* @param actual the value discovered instead of the default value
* @param newValue the new value requested in the command
* @param version the version of the entity in which the mismatch is discovered
* @return new {@code ValueMismatch} instance
*/
public static ValueMismatch expectedDefault(Message actual, Message newValue, int version) {
checkNotNull(actual);
checkNotNull(newValue);
final Message expectedDefault = actual.getDefaultInstanceForType();
return of(expectedDefault, actual, newValue, version);
}
use of com.google.protobuf.Message in project core-java by SpineEventEngine.
the class MessageMismatch method expectedNotDefault.
/**
* Creates a {@code ValueMismatch} for a command that wanted to <em>clear</em> a value,
* but discovered that the field already has the default value.
*
* @param expected the value of the field that the command wanted to clear
* @param version the version of the entity in which the mismatch is discovered
* @return new {@code ValueMismatch} instance
*/
public static ValueMismatch expectedNotDefault(Message expected, int version) {
checkNotNull(expected);
final Message defaultValue = expected.getDefaultInstanceForType();
return of(expected, defaultValue, defaultValue, version);
}
Aggregations