use of io.spine.server.entity.storage.EntityColumn.MemoizedValue 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.storage.EntityColumn.MemoizedValue in project core-java by SpineEventEngine.
the class RecordStorageShould method booleanColumn.
private static MemoizedValue booleanColumn(EntityColumn column, boolean value) {
final MemoizedValue memoizedValue = mock(MemoizedValue.class);
when(memoizedValue.getSourceColumn()).thenReturn(column);
when(memoizedValue.getValue()).thenReturn(value);
return memoizedValue;
}
use of io.spine.server.entity.storage.EntityColumn.MemoizedValue in project core-java by SpineEventEngine.
the class ColumnMemoizedValueShould method support_equality.
@Test
public void support_equality() {
/*
4 equality groups represent following cases:
A - 3 values of the same column memoized on the same instance of Entity;
A-mutated - the value of the same column on the same object but after the field change;
B - the value of a different column on the same instance;
C - the value of a mock column (used to ensure that MemoizedValue#equals is decoupled
from the EntityColumn#equals).
*/
final EntityColumn columnA = findColumn(TestEntity.class, MUTABLE_STATE_COLUMN);
final EntityColumn columnB = findColumn(TestEntity.class, ARCHIVED_COLUMN);
final EntityColumn columnC = mock(EntityColumn.class);
final TestEntity entity = new TestEntity("ID");
final MemoizedValue valueA1 = columnA.memoizeFor(entity);
final MemoizedValue valueA2 = columnA.memoizeFor(entity);
final MemoizedValue valueA3 = columnA.memoizeFor(entity);
entity.setMutableState(42);
final MemoizedValue valueAMutated = columnA.memoizeFor(entity);
final MemoizedValue valueB = columnB.memoizeFor(entity);
final MemoizedValue valueC = new MemoizedValue(columnC, entity.getState());
new EqualsTester().addEqualityGroup(valueA1, valueA2, valueA3).addEqualityGroup(valueAMutated).addEqualityGroup(valueB).addEqualityGroup(valueC).testEquals();
}
use of io.spine.server.entity.storage.EntityColumn.MemoizedValue in project core-java by SpineEventEngine.
the class ColumnMemoizedValueShould method be_serializable.
@Test
public void be_serializable() {
final EntityColumn column = findColumn(TestEntity.class, MUTABLE_STATE_COLUMN);
final TestEntity entity = new TestEntity("my-id");
entity.setMutableState(42);
final MemoizedValue value = column.memoizeFor(entity);
reserializeAndAssert(value);
}
use of io.spine.server.entity.storage.EntityColumn.MemoizedValue in project core-java by SpineEventEngine.
the class ColumnShould method memoize_value_regarding_nulls.
@Test
public void memoize_value_regarding_nulls() {
final EntityColumn nullableColumn = forMethod("getNull", TestEntity.class);
final MemoizedValue memoizedNull = nullableColumn.memoizeFor(new TestEntity(""));
assertTrue(memoizedNull.isNull());
assertNull(memoizedNull.getValue());
}
Aggregations