Search in sources :

Example 6 with StringValue

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

the class InvalidEntityStateExceptionShould method create_exception_with_violations.

@Test
public void create_exception_with_violations() {
    final StringValue entityState = StringValue.getDefaultInstance();
    final InvalidEntityStateException exception = onConstraintViolations(entityState, singletonList(ConstraintViolation.getDefaultInstance()));
    assertNotNull(exception.getMessage());
    assertNotNull(exception.getError());
    assertEquals(entityState, exception.getEntityState());
}
Also used : InvalidEntityStateException(io.spine.server.entity.InvalidEntityStateException) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 7 with StringValue

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

the class EntityIdFunctionShould method do_not_accept_wrong_id_type.

@Test(expected = IllegalStateException.class)
public void do_not_accept_wrong_id_type() {
    final Function<EntityId, StringValue> func = new RecordBasedRepository.EntityIdFunction<>(StringValue.class);
    final EntityId wrongType = EntityId.newBuilder().setId(Wrapper.forLong().pack(100L)).build();
    func.apply(wrongType);
}
Also used : EntityId(io.spine.client.EntityId) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 8 with StringValue

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

the class EntityShould method return_default_state_for_different_entities.

@Test
public void return_default_state_for_different_entities() {
    assertEquals(Project.getDefaultInstance(), entityNew.getDefaultState());
    final EntityWithMessageId entityWithMessageId = new EntityWithMessageId();
    final StringValue expected = StringValue.getDefaultInstance();
    assertEquals(expected, entityWithMessageId.getDefaultState());
}
Also used : StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 9 with StringValue

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

the class EntityShould method create_and_initialize_entity_instance.

@Test
public void create_and_initialize_entity_instance() {
    final Long id = 100L;
    final Timestamp before = TimeTests.Past.secondsAgo(1);
    // Create and init the entity.
    final Constructor<BareBonesEntity> ctor = getConstructor(BareBonesEntity.class, Long.class);
    final AbstractVersionableEntity<Long, StringValue> entity = createEntity(ctor, id);
    final Timestamp after = Time.getCurrentTime();
    // The interval with a much earlier start to allow non-zero interval on faster computers.
    final Interval whileWeCreate = Intervals.between(before, after);
    assertEquals(id, entity.getId());
    assertEquals(0, entity.getVersion().getNumber());
    assertTrue(Intervals.contains(whileWeCreate, entity.whenModified()));
    assertEquals(StringValue.getDefaultInstance(), entity.getState());
    assertFalse(entity.isArchived());
    assertFalse(entity.isDeleted());
}
Also used : StringValue(com.google.protobuf.StringValue) Timestamp(com.google.protobuf.Timestamp) Interval(io.spine.time.Interval) Test(org.junit.Test)

Example 10 with StringValue

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

the class EventsShould method setUp.

@Before
public void setUp() {
    final TestActorRequestFactory requestFactory = TestActorRequestFactory.newInstance(getClass());
    final Command cmd = requestFactory.command().create(Time.getCurrentTime());
    final StringValue producerId = Wrapper.forString(getClass().getSimpleName());
    EventFactory eventFactory = EventFactory.newBuilder().setCommandId(Commands.generateId()).setProducerId(producerId).setCommandContext(cmd.getContext()).build();
    event = eventFactory.createEvent(Time.getCurrentTime(), Tests.<Version>nullRef());
    context = event.getContext();
}
Also used : TestActorRequestFactory(io.spine.test.TestActorRequestFactory) Version(io.spine.base.Version) TestEventFactory(io.spine.test.TestEventFactory) EventFactory(io.spine.server.command.EventFactory) StringValue(com.google.protobuf.StringValue) Before(org.junit.Before)

Aggregations

StringValue (com.google.protobuf.StringValue)47 Test (org.junit.Test)41 Command (io.spine.base.Command)7 Timestamp (com.google.protobuf.Timestamp)5 Any (com.google.protobuf.Any)4 Event (io.spine.base.Event)4 Identifiers.idToString (io.spine.base.Identifiers.idToString)4 Wrapper.forString (io.spine.protobuf.Wrapper.forString)4 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)4 CommandContext (io.spine.base.CommandContext)3 EventFactory (io.spine.server.command.EventFactory)3 CommandBus (io.spine.server.commandbus.CommandBus)3 Version (io.spine.base.Version)2 EntityStateEnvelope (io.spine.server.entity.EntityStateEnvelope)2 TestActorRequestFactory (io.spine.test.TestActorRequestFactory)2 Before (org.junit.Before)2 EqualsTester (com.google.common.testing.EqualsTester)1 FieldMask (com.google.protobuf.FieldMask)1 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1 Message (com.google.protobuf.Message)1