use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ASegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest method testGapsWithReturnMaxResults.
@Test
public void testGapsWithReturnMaxResults() {
returnMaxResults = testReturnMaxResultsValue;
// once through the complete list
final List<FDate> liste = new ArrayList<FDate>();
for (final FDate entity : entities) {
final FDate cachedEntity = cache.query().getValue(entity);
liste.add(cachedEntity);
Assertions.assertThat(cachedEntity).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
Assertions.assertThat(liste).isEqualTo(entities);
// new maxKey without new db results
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addDays(5))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(7);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
// new minKey without new db limit
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().setFutureEnabled().getValue(entity.addYears(-5))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(7);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
// again in the same limit
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addDays(2))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(12);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
// random order
for (final FDate entity : new HashSet<FDate>(entities)) {
Assertions.assertThat(cache.query().getValue(entity.addDays(2))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(12);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
// simulate cache eviction
cache.clear();
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addDays(2))).isNotNull();
}
cache.clear();
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addDays(2))).isNotNull();
}
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(22);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(6);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ASegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest 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 ASegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest 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(7);
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(7);
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 ASegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest method testNoResultsUp.
@Test
public void testNoResultsUp() {
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addYears(100))).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 ASegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest 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(0);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
}
Aggregations