Search in sources :

Example 51 with StringValue

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);
}
Also used : CompositeColumnFilter(io.spine.client.CompositeColumnFilter) EntityFilters(io.spine.client.EntityFilters) ColumnFilter(io.spine.client.ColumnFilter) CompositeColumnFilter(io.spine.client.CompositeColumnFilter) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 52 with StringValue

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());
}
Also used : TestEventFactory(io.spine.server.command.TestEventFactory) Event(io.spine.core.Event) ExternalMessageEnvelope(io.spine.server.integration.ExternalMessageEnvelope) ExternalMessage(io.spine.server.integration.ExternalMessage) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 53 with StringValue

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());
}
Also used : InvalidEventException(io.spine.server.event.InvalidEventException) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 54 with StringValue

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());
}
Also used : StringValue(com.google.protobuf.StringValue) UnsupportedEventException(io.spine.server.event.UnsupportedEventException) Test(org.junit.Test)

Example 55 with StringValue

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());
}
Also used : Command(io.spine.core.Command) StringValue(com.google.protobuf.StringValue) Any(com.google.protobuf.Any) 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