Search in sources :

Example 81 with FDate

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

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testKeys.

@Test
public void testKeys() {
    final Iterable<FDate> iterable = cache.query().getKeys(FDate.MIN_DATE, FDate.MAX_DATE);
    final List<FDate> previousKeys = new ArrayList<FDate>();
    for (final FDate d : iterable) {
        previousKeys.add(d);
    }
    Assertions.assertThat(previousKeys).isEqualTo(entities);
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
}
Also used : ArrayList(java.util.ArrayList) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 82 with FDate

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

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNotCorrectTime.

@Test
public void testNotCorrectTime() {
    for (final FDate entity : entities.subList(1, entities.size() - 1)) {
        final FDate valueBefore = cache.query().getValue(entity.addHours(-3));
        Assertions.assertThat(valueBefore).isEqualTo(entity.addYears(-1));
        final FDate value = cache.query().getValue(entity);
        Assertions.assertThat(value).isEqualTo(entity);
        final FDate valueAfter = cache.query().getValue(entity.addHours(2));
        Assertions.assertThat(valueAfter).isEqualTo(entity);
    }
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 83 with FDate

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

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNoDataInReadAllValuesAscendingFrom.

@Test
public void testNoDataInReadAllValuesAscendingFrom() {
    returnNullInReadNewestValueTo = true;
    for (final FDate entity : entities) {
        final FDate cachedEntity = cache.query().getValue(entity);
        Assertions.assertThat(cachedEntity).isNotNull();
    }
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(1);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(2);
    // new minKey limit gets tested
    final Collection<FDate> values = asList(cache.query().setFutureEnabled().getPreviousValues(FDate.MIN_DATE, 5));
    for (final FDate d : values) {
        Assertions.assertThat(d).isEqualTo(entities.get(0));
    }
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
}
Also used : FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 84 with FDate

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

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest method testNextValueWithoutDistance.

@Test
public void testNextValueWithoutDistance() {
    FDate nextValue = cache.query().setFutureEnabled().getNextValue(entities.get(0), entities.size());
    Assertions.assertThat(nextValue).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(2);
    nextValue = cache.query().setFutureEnabled().getNextValue(entities.get(0), 1);
    Assertions.assertThat(nextValue).isEqualTo(entities.get(1));
    Assertions.assertThat(countReadAllValuesAscendingFrom).isEqualTo(2);
    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 85 with FDate

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

the class ALiveSegmentedTimeSeriesDBWithNoCacheTest 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(6);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
    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(6);
    Assertions.assertThat(countReadNewestValueTo).isEqualTo(3);
    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)

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