use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest method testNextKeyWithReturnMaxResults.
@Test
public void testNextKeyWithReturnMaxResults() {
returnMaxResults = testReturnMaxResultsValue;
FDate nextKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, entities.size());
Assertions.assertThat(nextKey).isEqualTo(entities.get(entities.size() - 1));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(3);
// 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(4);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest 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 ALiveSegmentedTimeSeriesDBWithLimitedCacheTest method testNoResultsUp.
@Test
public void testNoResultsUp() {
for (final FDate entity : entities) {
Assertions.assertThat(cache.query().getValue(entity.addYears(100))).isNotNull();
}
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 ALiveSegmentedTimeSeriesDBWithLimitedCacheTest 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(3);
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(3);
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 ALiveSegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest method testNewEntityIncomingPullingAdjustKeyProvider.
@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {
@Override
protected FDate innerGetHighestAllowedKey() {
return entities.get(entities.size() - 1);
}
@Override
protected boolean isPullingRecursive() {
return false;
}
});
final List<FDate> newEntities = new ArrayList<FDate>(entities);
final FDate newEntity = FDateBuilder.newDate(1996, 1, 1);
newEntities.add(newEntity);
for (final FDate entity : newEntities) {
final FDate value = cache.query().getValue(entity);
if (newEntity.equals(entity)) {
Assertions.assertThat(value).isNotEqualTo(newEntity);
Assertions.assertThat(value).isEqualTo(entities.get(entities.size() - 1));
} else {
Assertions.assertThat(value).isEqualTo(entity);
}
}
entities.add(newEntity);
table.putNextLiveValue(KEY, newEntity);
final FDate correctValue = cache.query().getValue(newEntity);
Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Aggregations