Search in sources :

Example 1 with LifecycleFlags

use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.

the class AggregateStorageVisibilityHandlingShould method write_entity_status_of_aggregate.

// Checked in an assertion
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
public void write_entity_status_of_aggregate() {
    final LifecycleFlags status = LifecycleFlags.newBuilder().setArchived(true).build();
    storage.writeLifecycleFlags(id, status);
    final Optional<LifecycleFlags> readStatus = storage.readLifecycleFlags(id);
    assertTrue(readStatus.isPresent());
    assertEquals(status, readStatus.get());
}
Also used : LifecycleFlags(io.spine.server.entity.LifecycleFlags) Test(org.junit.Test)

Example 2 with LifecycleFlags

use of io.spine.server.entity.LifecycleFlags 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 3 with LifecycleFlags

use of io.spine.server.entity.LifecycleFlags 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 4 with LifecycleFlags

use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.

the class AggregateStorageShould method read_history_of_archived_aggregate.

@Test
public void read_history_of_archived_aggregate() {
    final LifecycleFlags archivedRecordFlags = LifecycleFlags.newBuilder().setArchived(true).build();
    storage.writeLifecycleFlags(id, archivedRecordFlags);
    writeAndReadEventTest(id, storage);
}
Also used : LifecycleFlags(io.spine.server.entity.LifecycleFlags) Test(org.junit.Test)

Example 5 with LifecycleFlags

use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.

the class AggregateStorageShould method index_deleted_aggregate.

@Test
public void index_deleted_aggregate() {
    final LifecycleFlags deletedRecordFlags = LifecycleFlags.newBuilder().setDeleted(true).build();
    storage.writeRecord(id, StorageRecord.create(getCurrentTime()));
    storage.writeLifecycleFlags(id, deletedRecordFlags);
    assertTrue(storage.index().hasNext());
}
Also used : LifecycleFlags(io.spine.server.entity.LifecycleFlags) Test(org.junit.Test)

Aggregations

LifecycleFlags (io.spine.server.entity.LifecycleFlags)11 Test (org.junit.Test)8 EntityRecord (io.spine.server.entity.EntityRecord)2 MemoizedValue (io.spine.server.entity.storage.EntityColumn.MemoizedValue)1 EntityRecordWithColumns (io.spine.server.entity.storage.EntityRecordWithColumns)1