Search in sources :

Example 16 with EntityRecord

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);
    }
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) Project(io.spine.test.storage.Project) ProjectId(io.spine.test.storage.ProjectId) Any(com.google.protobuf.Any) Nullable(javax.annotation.Nullable)

Example 17 with EntityRecord

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);
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) StandStorage(io.spine.server.stand.StandStorage) ImmutableCollection(com.google.common.collect.ImmutableCollection) Collection(java.util.Collection) Test(org.junit.Test)

Example 18 with EntityRecord

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());
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) LifecycleFlags(io.spine.server.entity.LifecycleFlags) Test(org.junit.Test)

Example 19 with EntityRecord

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());
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) LifecycleFlags(io.spine.server.entity.LifecycleFlags) Test(org.junit.Test)

Example 20 with EntityRecord

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));
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) Project(io.spine.test.storage.Project) ProjectValidatingBuilder(io.spine.test.storage.ProjectValidatingBuilder) Identifiers.idToAny(io.spine.base.Identifiers.idToAny) Any(com.google.protobuf.Any) Test(org.junit.Test)

Aggregations

EntityRecord (io.spine.server.entity.EntityRecord)41 Test (org.junit.Test)24 Any (com.google.protobuf.Any)19 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)9 Message (com.google.protobuf.Message)8 TypeUrl (io.spine.type.TypeUrl)8 StandStorage (io.spine.server.stand.StandStorage)7 FieldMask (com.google.protobuf.FieldMask)6 Identifiers.idToAny (io.spine.base.Identifiers.idToAny)4 Project (io.spine.test.storage.Project)4 LinkedList (java.util.LinkedList)4 Version (io.spine.base.Version)3 EntityFilters (io.spine.client.EntityFilters)3 Project (io.spine.test.projection.Project)3 ImmutableList (com.google.common.collect.ImmutableList)2 Descriptors (com.google.protobuf.Descriptors)2 EntityIdFilter (io.spine.client.EntityIdFilter)2 LifecycleFlags (io.spine.server.entity.LifecycleFlags)2 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)2 Customer (io.spine.test.commandservice.customer.Customer)2