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