use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testOneResult.
@Test
public void testOneResult() {
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addYears(5))).isNotNull();
}
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 ALiveSegmentedTimeSeriesDBWithCacheTest 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(1);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest 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(4);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(4);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testPreviousValueWithQueryCacheWithJumpingAround.
@Test
public void testPreviousValueWithQueryCacheWithJumpingAround() {
// first
FDate previousValue = cache.query().getPreviousValue(entities.get(0), 1);
FDate expectedValue = entities.get(0);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(0);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(0);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
// last
previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), 1);
expectedValue = entities.get(entities.size() - 2);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(1);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
// first +1
previousValue = cache.query().getPreviousValue(entities.get(1), 1);
expectedValue = entities.get(0);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(2);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
// last -1
previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 2), 1);
expectedValue = entities.get(entities.size() - 3);
Assertions.assertThat(previousValue).isEqualTo(expectedValue);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(2);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testNextKeyWithAllValues.
@Test
public void testNextKeyWithAllValues() {
returnAllInReadAllValuesAscendingFrom = true;
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(1);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
Aggregations