use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testKeys.
@Test
public void testKeys() {
final Iterable<FDate> iterable = cache.query().getKeys(FDate.MIN_DATE, FDate.MAX_DATE);
final List<FDate> previousKeys = new ArrayList<FDate>();
for (final FDate d : iterable) {
previousKeys.add(d);
}
Assertions.assertThat(previousKeys).isEqualTo(entities);
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 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(4);
// 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).isEqualTo(4);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testPreviousKeyWithAllValuesAndNullInReadNewestValueTo.
@Test
public void testPreviousKeyWithAllValuesAndNullInReadNewestValueTo() {
returnAllInReadAllValuesAscendingFrom = true;
returnNullInReadNewestValueTo = true;
FDate previousKey = cache.query().getPreviousKey(new FDate(), entities.size());
Assertions.assertThat(previousKey).isEqualTo(entities.get(0));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
previousKey = cache.query().getPreviousKey(new FDate(), 1);
Assertions.assertThat(previousKey).isEqualTo(entities.get(entities.size() - 2));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousKeyWithAllValues.
@Test
public void testPreviousKeyWithAllValues() {
returnAllInReadAllValuesAscendingFrom = true;
FDate previousKey = cache.query().getPreviousKey(new FDate(), entities.size());
Assertions.assertThat(previousKey).isEqualTo(entities.get(0));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
previousKey = cache.query().getPreviousKey(new FDate(), 1);
Assertions.assertThat(previousKey).isEqualTo(entities.get(entities.size() - 2));
Assertions.assertThat(countReadAllValuesAscendingFrom).isLessThanOrEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testPreviousValuesFilterDuplicateKeys.
@Test
public void testPreviousValuesFilterDuplicateKeys() {
Assertions.assertThat(asList(cache.query().getPreviousValues(new FDate(), 100)).size()).isSameAs(6);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(5);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(asList(cache.query().getPreviousValues(new FDate(), 100)).size()).isEqualTo(entities.size());
Assertions.assertThat(countReadAllValuesAscendingFrom).isLessThanOrEqualTo(11);
Assertions.assertThat(countReadNewestValueTo).isLessThanOrEqualTo(11);
}
Aggregations