Search in sources :

Example 61 with StringValue

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

the class EventsShould method obtain_type_name_of_event.

@Test
public void obtain_type_name_of_event() {
    final CommandEnvelope command = requestFactory.generateEnvelope();
    final StringValue producerId = toMessage(getClass().getSimpleName());
    final EventFactory ef = EventFactory.on(command, Identifier.pack(producerId));
    final Event event = ef.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    final TypeName typeName = EventEnvelope.of(event).getTypeName();
    assertNotNull(typeName);
    assertEquals(Timestamp.class.getSimpleName(), typeName.getSimpleName());
}
Also used : TypeName(io.spine.type.TypeName) EventFactory(io.spine.server.event.EventFactory) GivenEvent(io.spine.core.given.GivenEvent) StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Events.getTimestamp(io.spine.core.Events.getTimestamp) Test(org.junit.Test)

Example 62 with StringValue

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

the class EventsShould method obtain_root_command_id.

@Test
public void obtain_root_command_id() {
    final CommandEnvelope command = requestFactory.generateEnvelope();
    final StringValue producerId = toMessage(getClass().getSimpleName());
    final EventFactory ef = EventFactory.on(command, Identifier.pack(producerId));
    final Event event = ef.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    assertEquals(command.getId(), Events.getRootCommandId(event));
}
Also used : EventFactory(io.spine.server.event.EventFactory) GivenEvent(io.spine.core.given.GivenEvent) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 63 with StringValue

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

the class PairShould method allow_optional_B_absent.

@Test
public void allow_optional_B_absent() {
    StringValue a = TestValues.newUuidValue();
    Optional<BoolValue> b = Optional.absent();
    Pair<StringValue, Optional<BoolValue>> pair = Pair.withNullable(a, null);
    assertEquals(a, pair.getA());
    assertEquals(b, pair.getB());
}
Also used : Optional(com.google.common.base.Optional) BoolValue(com.google.protobuf.BoolValue) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 64 with StringValue

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

the class PairShould method return_values.

@Test
public void return_values() {
    StringValue a = TestValues.newUuidValue();
    BoolValue b = BoolValue.of(true);
    Pair<StringValue, BoolValue> pair = Pair.of(a, b);
    assertEquals(a, pair.getA());
    assertEquals(b, pair.getB());
}
Also used : BoolValue(com.google.protobuf.BoolValue) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 65 with StringValue

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

the class PairShould method support_equality.

@Test
public void support_equality() {
    final StringValue v1 = TestValues.newUuidValue();
    final StringValue v2 = TestValues.newUuidValue();
    final Pair<StringValue, StringValue> p1 = Pair.of(v1, v2);
    final Pair<StringValue, StringValue> p1a = Pair.of(v1, v2);
    final Pair<StringValue, StringValue> p2 = Pair.of(v2, v1);
    new EqualsTester().addEqualityGroup(p1, p1a).addEqualityGroup(p2).testEquals();
}
Also used : EqualsTester(com.google.common.testing.EqualsTester) StringValue(com.google.protobuf.StringValue) 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