Search in sources :

Example 1 with APullingHistoricalCacheAdjustKeyProvider

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

the class ALiveSegmentedTimeSeriesDBWithCacheTest 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);
    table.putNextLiveValue(KEY, 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 2 with APullingHistoricalCacheAdjustKeyProvider

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

the class ALiveSegmentedTimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest 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);
    table.putNextLiveValue(KEY, 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 3 with APullingHistoricalCacheAdjustKeyProvider

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

the class ASegmentedTimeSeriesDBWithCacheTest 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 4 with APullingHistoricalCacheAdjustKeyProvider

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

the class ATimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest 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 5 with APullingHistoricalCacheAdjustKeyProvider

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

the class ATimeSeriesDBWithUnlimitedCacheTest 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