use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest 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(3);
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(4);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNoResultsDown.
@Test
public void testNoResultsDown() {
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().setFutureEnabled().getValue(entity.addYears(-100))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(8);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testInconsistentGapKey.
@Test
public void testInconsistentGapKey() {
FDate searchedKey = entities.get(0);
FDate value = cache.query().getValue(searchedKey);
Assertions.assertThat(value).isEqualTo(searchedKey);
searchedKey = entities.get(1);
value = cache.query().getValue(searchedKey.addDays(1));
Assertions.assertThat(value).isEqualTo(searchedKey);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testPreviousKeysFilterDuplicateKeys.
@Test
public void testPreviousKeysFilterDuplicateKeys() {
Assertions.assertThat(asList(cache.query().getPreviousKeys(new FDate(), 100)).size()).isSameAs(6);
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(6);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
Assertions.assertThat(asList(cache.query().getPreviousKeys(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 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(6);
// 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(6);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
Aggregations