use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest 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(11);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(6);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest 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 ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest 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 ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest 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(6);
// loading newest entity is faster than always loading all entities
Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
previousValue = cache.query().getPreviousValue(new FDate(), 1);
Assertions.assertThat(previousValue).isEqualTo(entities.get(entities.size() - 2));
Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(8);
Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.
the class ALiveSegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest method testGetPreviousAndNextEntry.
@Test
public void testGetPreviousAndNextEntry() {
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().getPreviousEntry(entities.get(entities.size() - 1), i));
final FDate expectedValue = entities.get(entities.size() - i - 1);
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().getPreviousEntry(FDate.MAX_DATE, i));
final FDate expectedValue = entities.get(entities.size() - i - 1);
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().setFutureEnabled().getPreviousEntry(FDate.MIN_DATE, i));
// filtering query removes the result because it is not a previous result
final FDate expectedValue = null;
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().setFutureEnabled().getNextEntry(entities.get(0), i));
final FDate expectedValue = entities.get(i);
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().setFutureEnabled().getNextEntry(FDate.MIN_DATE, i));
final FDate expectedValue = entities.get(i);
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
for (int i = 0; i < entities.size(); i++) {
final FDate value = IHistoricalEntry.unwrapEntryValue(cache.query().setFutureEnabled().getNextEntry(FDate.MAX_DATE, i));
// filtering query removes the result because it is not a previous result
final FDate expectedValue = null;
Assertions.checkEquals(value, expectedValue, i + ": expected [" + expectedValue + "] got [" + value + "]");
}
}
Aggregations