Search in sources :

Example 16 with StringValue

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

the class ProcessManagerShould method create_router.

@Test
public void create_router() {
    final StringValue commandMessage = toMessage("create_router");
    final CommandContext commandContext = requestFactory.createCommandContext();
    processManager.injectCommandBus(mock(CommandBus.class));
    final CommandRouter router = processManager.newRouterFor(commandMessage, commandContext);
    assertNotNull(router);
    assertEquals(commandMessage, getMessage(router.getSource()));
    assertEquals(commandContext, router.getSource().getContext());
}
Also used : CommandContext(io.spine.core.CommandContext) CommandBus(io.spine.server.commandbus.CommandBus) StringValue(com.google.protobuf.StringValue) TenantAwareTest(io.spine.server.tenant.TenantAwareTest) Test(org.junit.Test)

Example 17 with StringValue

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

the class ProjectionRepositoryShould method log_error_if_dispatch_unknown_event.

@Test
public void log_error_if_dispatch_unknown_event() {
    final StringValue unknownEventMessage = StringValue.getDefaultInstance();
    final Event event = GivenEvent.withMessage(unknownEventMessage);
    repository().dispatch(EventEnvelope.of(event));
    TestProjectionRepository testRepo = (TestProjectionRepository) repository();
    assertTrue(testRepo.getLastErrorEnvelope() instanceof EventEnvelope);
    assertEquals(Events.getMessage(event), testRepo.getLastErrorEnvelope().getMessage());
    assertEquals(event, testRepo.getLastErrorEnvelope().getOuterObject());
    // It must be "illegal argument type" since projections of this repository
    // do not handle such events.
    assertTrue(testRepo.getLastException() instanceof IllegalArgumentException);
}
Also used : EventEnvelope(io.spine.core.EventEnvelope) GivenEvent(io.spine.core.given.GivenEvent) Event(io.spine.core.Event) StringValue(com.google.protobuf.StringValue) TestProjectionRepository(io.spine.server.projection.given.ProjectionRepositoryTestEnv.TestProjectionRepository) Test(org.junit.Test)

Example 18 with StringValue

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

the class EntityClassShould 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 EntityClass<NanoEntity> entityClass = new EntityClass<>(NanoEntity.class);
    final AbstractVersionableEntity<Long, StringValue> entity = entityClass.createEntity(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 19 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(toAny(100L)).build();
    func.apply(wrongType);
}
Also used : EntityId(io.spine.client.EntityId) StringValue(com.google.protobuf.StringValue) Test(org.junit.Test)

Example 20 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 : 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