Search in sources :

Example 71 with FDate

use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNextKeyWithAllValues.

@Test
public void testNextKeyWithAllValues() {
    returnAllInReadAllValuesAscendingFrom = true;
    FDate nextKey = cache.query().setFutureEnabled().getNextKey(FDate.MIN_DATE, entities.size());
    Assertions.assertThat(nextKey).isEqualTo(entities.get(entities.size() - 1));
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
    // 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(2);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 72 with FDate

use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.

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

Example 73 with FDate

use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.

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

Example 74 with FDate

use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest 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(7);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(4);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 75 with FDate

use of de.invesdwin.util.time.date.FDate in project invesdwin-context-persistence by subes.

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testPreviousValueWithoutDistance.

@Test
public void testPreviousValueWithoutDistance() {
    FDate previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), 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(2);
    previousValue = cache.query().getPreviousValue(entities.get(entities.size() - 1), 1);
    Assertions.assertThat(previousValue).isEqualTo(entities.get(entities.size() - 2));
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(6);
    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