use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testNewEntityIncomingPushingAdjustKeyProvider.
@Test
public void testNewEntityIncomingPushingAdjustKeyProvider() throws IncompleteUpdateFoundException {
final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {
@Override
protected FDate getInitialHighestAllowedKey() {
return null;
}
@Override
protected boolean isPullingRecursive() {
return false;
}
};
cache.setAdjustKeyProvider(adjustKeyProvider);
adjustKeyProvider.pushHighestAllowedKey(entities.get(entities.size() - 1));
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);
}
}
adjustKeyProvider.pushHighestAllowedKey(newEntity);
entities.add(newEntity);
table.putNextLiveValue(KEY, newEntity);
final FDate correctValue = cache.query().getValue(newEntity);
Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testValues.
@Test
public void testValues() {
final Iterable<FDate> iterable = cache.query().getValues(entities.get(0).addMilliseconds(1), FDate.MAX_DATE);
final List<FDate> previousKeys = new ArrayList<FDate>();
for (final FDate d : iterable) {
previousKeys.add(d);
}
Assertions.assertThat(previousKeys).isEqualTo(entities.subList(1, entities.size()));
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 testNextValuesGetsFilledUpWithoutDistance.
@Test
public void testNextValuesGetsFilledUpWithoutDistance() {
final Collection<FDate> nextValues = asList(cache.query().setFutureEnabled().getNextValues(entities.get(entities.size() - 1), entities.size()));
Assertions.assertThat(nextValues.size()).isEqualTo(1);
for (final FDate d : nextValues) {
Assertions.assertThat(d).isEqualTo(entities.get(entities.size() - 1));
}
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 ALiveSegmentedTimeSeriesDBWithCacheTest method testPreviousValueKeyBetween.
@Test
public void testPreviousValueKeyBetween() {
for (int i = 0; i < entities.size(); i++) {
final FDate entity = entities.get(i);
final FDate foundKey = cache.query().getPreviousKeyWithSameValueBetween(FDate.MIN_DATE, FDate.MAX_DATE, entity);
Assertions.assertThat(foundKey).isEqualTo(entity);
}
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithCacheTest method testPreviousValueKeyBetweenReverse.
@Test
public void testPreviousValueKeyBetweenReverse() {
for (int i = entities.size() - 1; i >= 0; i--) {
final FDate entity = entities.get(i);
final FDate foundKey = cache.query().getPreviousKeyWithSameValueBetween(FDate.MIN_DATE, FDate.MAX_DATE, entity);
Assertions.assertThat(foundKey).isEqualTo(entity);
}
}
Aggregations