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());
}
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);
}
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());
}
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);
}
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());
}
Aggregations