use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testSubListWhenSwitchingFromFilterToNonFilter.
@Test
public void testSubListWhenSwitchingFromFilterToNonFilter() {
final FDate key = new FDate();
final Collection<FDate> previousValues = asList(cache.query().getPreviousValues(key, 10));
final List<FDate> expectedValues = entities;
Assertions.assertThat(previousValues).isEqualTo(expectedValues);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(5);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
final Collection<FDate> previousValuesCached = asList(cache.query().getPreviousValues(key, 10));
Assertions.assertThat(previousValuesCached).isEqualTo(entities);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(countInnerExtractKey).isEqualTo(5);
Assertions.assertThat(countAdjustKey).isEqualTo(0);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousValueWithDistance.
@Test
public void testPreviousValueWithDistance() {
FDate previousValue = cache.query().getPreviousValue(new FDate(), entities.size());
Assertions.assertThat(previousValue).isEqualTo(entities.get(0));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
previousValue = cache.query().getPreviousValue(new FDate(), 1);
Assertions.assertThat(previousValue).isEqualTo(entities.get(entities.size() - 2));
Assertions.assertThat(countReadAllValuesAscendingFrom).isLessThanOrEqualTo(7);
Assertions.assertThat(countReadNewestValueTo).isLessThanOrEqualTo(9);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousValueWithoutDistance.
@Test
public void testPreviousValueWithoutDistance() {
FDate previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), entities.size());
Assertions.assertThat(previousValue).isEqualTo(entities.get(0));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), 1);
Assertions.assertThat(previousValue).isEqualTo(entities.get(entities.size() - 2));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testPreviousValuesFilterDuplicateKeys.
@Test
public void testPreviousValuesFilterDuplicateKeys() {
Assertions.assertThat(asList(cache.query().getPreviousValues(new FDate(), 100)).size()).isSameAs(6);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(6);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
Assertions.assertThat(asList(cache.query().getPreviousValues(new FDate(), 100)).size()).isEqualTo(entities.size());
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(7);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNextKey.
@Test
public void testNextKey() {
FDate previousKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(previousKey).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(3);
previousKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, 1);
Assertions.assertThat(previousKey).isEqualTo(entities.get(1));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
Aggregations