use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class RecordBasedRepositoryShould method find_entities_by_query.
@Test
public void find_entities_by_query() {
final I id1 = createId(271);
final I id2 = createId(314);
final Class<E> entityClass = repository.getEntityClass();
final E entity1 = Given.entityOfClass(entityClass).withId(id1).build();
final E entity2 = Given.entityOfClass(entityClass).withId(id2).build();
repository.store(entity1);
repository.store(entity2);
final String fieldPath = "idString";
final StringValue fieldValue = StringValue.newBuilder().setValue(id1.toString()).build();
final ColumnFilter filter = eq(fieldPath, fieldValue);
final CompositeColumnFilter aggregatingFilter = CompositeColumnFilter.newBuilder().addFilter(filter).setOperator(ALL).build();
final EntityFilters filters = EntityFilters.newBuilder().addFilter(aggregatingFilter).build();
final Collection<E> found = newArrayList(repository.find(filters, FieldMask.getDefaultInstance()));
assertSize(1, found);
assertContains(entity1, found);
assertNotContains(entity2, found);
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class DelegatingEventDispatcherShould method expose_external_dispatcher_that_delegates_onError.
@Test
public void expose_external_dispatcher_that_delegates_onError() {
final ExternalMessageDispatcher<String> extMessageDispatcher = delegatingDispatcher.getExternalDispatcher();
final TestEventFactory factory = TestEventFactory.newInstance(getClass());
final StringValue eventMsg = newUuidValue();
final Event event = factory.createEvent(eventMsg);
final ExternalMessage externalMessage = ExternalMessages.of(event, BoundedContext.newName(getClass().getName()));
final ExternalMessageEnvelope externalMessageEnvelope = ExternalMessageEnvelope.of(externalMessage, eventMsg);
final RuntimeException exception = new RuntimeException("test external dispatcher delegating onError");
extMessageDispatcher.onError(externalMessageEnvelope, exception);
assertTrue(delegate.onErrorCalled());
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class InvalidEventExceptionShould method create_exception_with_violations.
@Test
public void create_exception_with_violations() {
final StringValue msg = toMessage("");
final InvalidEventException exception = InvalidEventException.onConstraintViolations(msg, singletonList(ConstraintViolation.getDefaultInstance()));
assertNotNull(exception.getMessage());
assertNotNull(exception.asError());
assertEquals(msg, exception.getEventMessage());
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class UnsupportedEventExceptionShould method have_msg_and_error.
@Test
public void have_msg_and_error() {
final StringValue msg = toMessage("");
final UnsupportedEventException exception = new UnsupportedEventException(msg);
assertNotNull(exception.getMessage());
assertNotNull(exception.asError());
assertEquals(msg, exception.getEventMessage());
}
use of com.google.protobuf.StringValue in project core-java by SpineEventEngine.
the class IteratingCommandRouterShould method return_CommandRouted_from_routeFirst.
@Test
public void return_CommandRouted_from_routeFirst() throws Exception {
final CommandRouted commandRouted = router().routeFirst();
assertSource(commandRouted);
// Test that only only one command was produced by `routeFirst()`.
assertEquals(1, commandRouted.getProducedCount());
// Test that there's only one produced command and it has correct message.
final Command produced = commandRouted.getProduced(0);
final StringValue commandMessage = Commands.getMessage(produced);
assertEquals(messages().get(0), commandMessage);
assertActorAndTenant(produced);
// Test that the event contains messages to follow.
assertEquals(messages().size() - 1, commandRouted.getMessageToFollowCount());
final List<Any> messageToFollow = commandRouted.getMessageToFollowList();
assertArrayEquals(messages().subList(1, messages().size()).toArray(), unpackAll(messageToFollow).toArray());
}
Aggregations