use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.
the class AggregateStorageShould method index_archived_aggregate.
@Test
public void index_archived_aggregate() {
final LifecycleFlags archivedRecordFlags = LifecycleFlags.newBuilder().setArchived(true).build();
storage.writeRecord(id, StorageRecord.create(getCurrentTime()));
storage.writeLifecycleFlags(id, archivedRecordFlags);
assertTrue(storage.index().hasNext());
}
use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.
the class RecordStorageShould method withLifecycleColumns.
protected static EntityRecordWithColumns withLifecycleColumns(EntityRecord record) {
final LifecycleFlags flags = record.getLifecycleFlags();
final Map<String, MemoizedValue> columns = ImmutableMap.of(LifecycleColumns.ARCHIVED.columnName(), booleanColumn(LifecycleColumns.ARCHIVED.column(), flags.getArchived()), LifecycleColumns.DELETED.columnName(), booleanColumn(LifecycleColumns.DELETED.column(), flags.getDeleted()));
final EntityRecordWithColumns result = createRecord(record, columns);
return result;
}
use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.
the class AggregateMessageEndpoint method deliverNowTo.
@Override
protected void deliverNowTo(I aggregateId) {
final A aggregate = repository().loadOrCreate(aggregateId);
final LifecycleFlags flagsBefore = aggregate.getLifecycleFlags();
final List<? extends Message> eventMessages = doDispatch(aggregate, envelope());
final AggregateTransaction tx = startTransaction(aggregate);
aggregate.apply(eventMessages, envelope());
tx.commit();
// Update lifecycle flags only if the message was handled successfully and flags changed.
final LifecycleFlags flagsAfter = aggregate.getLifecycleFlags();
if (flagsAfter != null && !flagsBefore.equals(flagsAfter)) {
storage().writeLifecycleFlags(aggregateId, flagsAfter);
}
store(aggregate);
}
use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.
the class AggregateStorageVisibilityHandlingShould method save_whole_status.
@Test
public void save_whole_status() {
final boolean archived = true;
final boolean deleted = true;
final LifecycleFlags expected = LifecycleFlags.newBuilder().setArchived(archived).setDeleted(deleted).build();
storage.writeLifecycleFlags(id, expected);
final Optional<LifecycleFlags> optionalActual = storage.readLifecycleFlags(id);
assertStatus(optionalActual, true, true);
}
use of io.spine.server.entity.LifecycleFlags in project core-java by SpineEventEngine.
the class AggregateStorageVisibilityHandlingShould method assertStatus.
@SuppressWarnings({ "OptionalUsedAsFieldOrParameterType", "OptionalGetWithoutIsPresent" })
private static void assertStatus(Optional<LifecycleFlags> entityStatus, boolean archived, boolean deleted) {
assertTrue(entityStatus.isPresent());
final LifecycleFlags status = entityStatus.get();
assertEquals(archived, status.getArchived());
assertEquals(deleted, status.getDeleted());
}
Aggregations