use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class StandStorageShould method checkIds.
protected void checkIds(List<AggregateStateId> ids, Collection<EntityRecord> records) {
assertSize(ids.size(), records);
final Collection<ProjectId> projectIds = Collections2.transform(ids, new Function<AggregateStateId, ProjectId>() {
@Nullable
@Override
public ProjectId apply(@Nullable AggregateStateId input) {
if (input == null) {
return null;
}
return (ProjectId) input.getAggregateId();
}
});
for (EntityRecord record : records) {
final Any packedState = record.getState();
final Project state = AnyPacker.unpack(packedState);
final ProjectId id = state.getId();
assertContains(id, projectIds);
}
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class StandStorageShould method retrieve_records_by_ids.
@Test
public void retrieve_records_by_ids() {
final StandStorage storage = getStorage();
// Use a subset of IDs
final List<AggregateStateId> ids = fill(storage, 10, DEFAULT_ID_SUPPLIER).subList(0, 5);
final Collection<EntityRecord> records = (Collection<EntityRecord>) storage.readMultiple(ids);
checkIds(ids, records);
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class RecordStorageShould method load_visibility_when_updated.
// We verify in assertion.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void load_visibility_when_updated() {
final I id = newId();
final EntityRecord record = newStorageRecord(id);
final RecordStorage<I> storage = getStorage();
storage.write(id, EntityRecordWithColumns.of(record));
storage.writeLifecycleFlags(id, archived());
final Optional<LifecycleFlags> optional = storage.readLifecycleFlags(id);
assertTrue(optional.isPresent());
assertTrue(optional.get().getArchived());
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class RecordStorageShould method return_default_visibility_for_new_record.
// Converter nullability issues
@SuppressWarnings("ConstantConditions")
@Test
public void return_default_visibility_for_new_record() {
final I id = newId();
final EntityRecord record = newStorageRecord(id);
final RecordStorage<I> storage = getStorage();
storage.write(id, record);
final Optional<LifecycleFlags> optional = storage.readLifecycleFlags(id);
assertTrue(optional.isPresent());
assertEquals(LifecycleFlags.getDefaultInstance(), optional.get());
}
use of io.spine.server.entity.EntityRecord in project core-java by SpineEventEngine.
the class RecordStorageShould method write_none_storage_fields_is_none_passed.
@Test
public void write_none_storage_fields_is_none_passed() {
final RecordStorage<I> storage = spy(getStorage());
final I id = newId();
final Any state = AnyPacker.pack(Sample.messageOfType(Project.class));
final EntityRecord record = Sample.<EntityRecord, EntityRecord.Builder>builderForType(EntityRecord.class).setState(state).build();
storage.write(id, record);
verify(storage).write(eq(id), withRecordAndNoFields(record));
}
Aggregations