Search in sources :

Example 1 with FDate

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);
}
Also used : ArrayList(java.util.ArrayList) FDate(de.invesdwin.util.time.date.FDate) HashSet(java.util.HashSet) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 2 with FDate

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);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 3 with FDate

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);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 4 with FDate

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);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 5 with FDate

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);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Aggregations

FDate (de.invesdwin.util.time.date.FDate)1046 Test (org.junit.jupiter.api.Test)942 ATest (de.invesdwin.context.test.ATest)921 ArrayList (java.util.ArrayList)255 IEvaluateGenericFDate (de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate)97 Instant (de.invesdwin.util.time.Instant)78 LoopInterruptedCheck (de.invesdwin.util.concurrent.loop.LoopInterruptedCheck)63 APushingHistoricalCacheAdjustKeyProvider (de.invesdwin.util.collections.loadingcache.historical.key.APushingHistoricalCacheAdjustKeyProvider)54 HashSet (java.util.HashSet)36 NoSuchElementException (java.util.NoSuchElementException)34 TimeRange (de.invesdwin.util.time.range.TimeRange)27 File (java.io.File)26 ICloseableIterable (de.invesdwin.util.collections.iterable.ICloseableIterable)20 List (java.util.List)20 Pair (de.invesdwin.util.bean.tuple.Pair)18 APullingHistoricalCacheAdjustKeyProvider (de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider)18 Collection (java.util.Collection)18 PreparedStatement (java.sql.PreparedStatement)16 ResultSet (java.sql.ResultSet)15 Duration (de.invesdwin.util.time.duration.Duration)13