use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testNextKey.
@Test
public void testNextKey() {
FDate nextKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(nextKey).isEqualTo(entities.get(entities.size() - 1));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
nextKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, 1);
Assertions.assertThat(nextKey).isEqualTo(entities.get(1));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testNotCorrectTime.
@Test
public void testNotCorrectTime() {
for (final FDate entity : entities.subList(1, entities.size() - 1)) {
final FDate valueBefore = cache.query().getValue(entity.addHours(-3));
Assertions.assertThat(valueBefore).isEqualTo(entity.addYears(-1));
final FDate value = cache.query().getValue(entity);
Assertions.assertThat(value).isEqualTo(entity);
final FDate valueAfter = cache.query().getValue(entity.addHours(2));
Assertions.assertThat(valueAfter).isEqualTo(entity);
}
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousValueWithQueryCacheWithIncrementingKey.
@Test
public void testPreviousValueWithQueryCacheWithIncrementingKey() {
for (int index = 0; index < entities.size(); index++) {
final FDate previousValue = cache.query().getPreviousValue(entities.get(index), index + 1);
final FDate expectedValue = entities.get(0);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
Assertions.assertThat(countInnerExtractKey).isEqualTo(1);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousKeyBeforeFirstReverse.
@Test
public void testPreviousKeyBeforeFirstReverse() {
FDate previousKey = cache.query().setFutureNullEnabled().getPreviousKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(previousKey).isEqualTo(FDate.MIN_DATE);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(0);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
previousKey = cache.query().setFutureEnabled().getPreviousKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(previousKey).isEqualTo(FDate.MIN_DATE);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(0);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
previousKey = cache.query().setFutureNullEnabled().getPreviousKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(previousKey).isEqualTo(FDate.MIN_DATE);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(0);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousValueWithQueryCacheWithAlwaysSameKey.
@Test
public void testPreviousValueWithQueryCacheWithAlwaysSameKey() {
for (int size = 1; size < entities.size(); size++) {
final FDate previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), size);
final FDate expectedValue = entities.get(entities.size() - size - 1);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(5);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
}
Aggregations