Search in sources :

Example 71 with StringValue

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

the class CommandsShould method extract_message_from_command.

@Test
public void extract_message_from_command() {
    final StringValue message = toMessage("extract_message_from_command");
    final Command command = requestFactory.createCommand(message);
    assertEquals(message, Commands.getMessage(command));
}
Also used : StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 72 with StringValue

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

the class CommandsShould method obtain_type_url_of_command.

@Test
public void obtain_type_url_of_command() {
    final ActorRequestFactory factory = TestActorRequestFactory.newInstance(CommandsShould.class);
    final StringValue message = toMessage(Identifier.newUuid());
    final Command command = factory.command().create(message);
    final TypeUrl typeUrl = CommandEnvelope.of(command).getTypeName().toUrl();
    assertEquals(TypeUrl.of(StringValue.class), typeUrl);
}
Also used : ActorRequestFactory(io.spine.client.ActorRequestFactory) TestActorRequestFactory(io.spine.client.TestActorRequestFactory) TypeUrl(io.spine.type.TypeUrl) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 73 with StringValue

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

the class AggregateMessageDispatcherShould method dispatch_event.

@Test
public void dispatch_event() {
    final TestEventFactory factory = TestEventFactory.newInstance(getClass());
    final float messageValue = 2017.0729f;
    final FloatValue message = FloatValue.newBuilder().setValue(messageValue).build();
    final EventEnvelope eventEnvelope = EventEnvelope.of(factory.createEvent(message));
    final List<? extends Message> eventMessages = dispatchEvent(aggregate, eventEnvelope);
    assertTrue(aggregate.getState().getValue().contains(String.valueOf(messageValue)));
    assertEquals(1, eventMessages.size());
    assertTrue(eventMessages.get(0) instanceof StringValue);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) TestEventFactory(io.spine.server.command.TestEventFactory) FloatValue(com.google.protobuf.FloatValue) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 74 with StringValue

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

the class CommandTestShould method createAndAssertCommand.

/**
 * Creates a new command and checks its content.
 *
 * <p>If the method completes, we assume that the passed command test
 * has correctly working {@link ActorRequestFactory}.
 */
private static void createAndAssertCommand(CommandTest<StringValue> commandTest) {
    final StringValue commandMessage = newUuidValue();
    final Command command = commandTest.createCommand(commandMessage);
    checkNotDefault(command);
    assertEquals(commandMessage, Commands.getMessage(command));
    checkNotDefault(command.getContext());
}
Also used : Command(io.spine.core.Command) StringValue(com.google.protobuf.StringValue)

Example 75 with StringValue

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

the class EntityBuilderShould method create_entity.

@Test
public void create_entity() {
    final long id = 1024L;
    final int version = 100500;
    final StringValue state = toMessage(getClass().getName());
    final Timestamp timestamp = Time.getCurrentTime();
    final VersionableEntity entity = givenEntity().withId(id).withVersion(version).withState(state).modifiedOn(timestamp).build();
    assertEquals(TestEntity.class, entity.getClass());
    assertEquals(id, entity.getId());
    assertEquals(state, entity.getState());
    assertEquals(version, entity.getVersion().getNumber());
    assertEquals(timestamp, entity.getVersion().getTimestamp());
}
Also used : StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) 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