Search in sources :

Example 11 with APullingHistoricalCacheAdjustKeyProvider

use of de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider in project invesdwin-context-persistence by subes.

the class ATimeSeriesDBWithCacheTest method testNewEntityIncomingPullingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate innerGetHighestAllowedKey() {
            return entities.get(entities.size() - 1);
        }

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    });
    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);
        }
    }
    entities.add(newEntity);
    updater.update();
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : ArrayList(java.util.ArrayList) APullingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 12 with APullingHistoricalCacheAdjustKeyProvider

use of de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider in project invesdwin-context-persistence by subes.

the class ASegmentedTimeSeriesDBWithLimitedCacheTest method testNewEntityIncomingPullingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate innerGetHighestAllowedKey() {
            return entities.get(entities.size() - 1);
        }

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    });
    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);
        }
    }
    entities.add(newEntity);
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : ArrayList(java.util.ArrayList) APullingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 13 with APullingHistoricalCacheAdjustKeyProvider

use of de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider in project invesdwin-context-persistence by subes.

the class ASegmentedTimeSeriesDBWithNoCacheTest method testNewEntityIncomingPullingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate innerGetHighestAllowedKey() {
            return entities.get(entities.size() - 1);
        }

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    });
    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);
        }
    }
    entities.add(newEntity);
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : ArrayList(java.util.ArrayList) APullingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 14 with APullingHistoricalCacheAdjustKeyProvider

use of de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider in project invesdwin-context-persistence by subes.

the class ASegmentedTimeSeriesDBWithNoCacheAndNoQueryCacheTest method testNewEntityIncomingPullingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate innerGetHighestAllowedKey() {
            return entities.get(entities.size() - 1);
        }

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    });
    final List<FDate> newEntities = new ArrayList<FDate>(entities);
    final FDate newEntity = FDateBuilder.newDate(1997, 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);
        }
    }
    entities.add(newEntity);
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : ArrayList(java.util.ArrayList) APullingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider) IEvaluateGenericFDate(de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Example 15 with APullingHistoricalCacheAdjustKeyProvider

use of de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider in project invesdwin-context-persistence by subes.

the class ATimeSeriesDBWithNoCacheTest method testNewEntityIncomingPullingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPullingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    cache.setAdjustKeyProvider(new APullingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate innerGetHighestAllowedKey() {
            return entities.get(entities.size() - 1);
        }

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    });
    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);
        }
    }
    entities.add(newEntity);
    updater.update();
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : ArrayList(java.util.ArrayList) APullingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider) FDate(de.invesdwin.util.time.date.FDate) ATest(de.invesdwin.context.test.ATest) Test(org.junit.jupiter.api.Test)

Aggregations

ATest (de.invesdwin.context.test.ATest)18 APullingHistoricalCacheAdjustKeyProvider (de.invesdwin.util.collections.loadingcache.historical.key.APullingHistoricalCacheAdjustKeyProvider)18 FDate (de.invesdwin.util.time.date.FDate)18 ArrayList (java.util.ArrayList)18 Test (org.junit.jupiter.api.Test)18 IEvaluateGenericFDate (de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate)2