Search in sources :

Example 11 with APushingHistoricalCacheAdjustKeyProvider

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

the class ATimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest method testNewEntityIncomingPushingAdjustKeyProviderWithoutPush.

@Test
public void testNewEntityIncomingPushingAdjustKeyProviderWithoutPush() throws IncompleteUpdateFoundException {
    final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {

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

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

Example 12 with APushingHistoricalCacheAdjustKeyProvider

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

the class ATimeSeriesDBWithoutShiftKeysAndQueryInterceptorTest method testNewEntityIncomingPushingAdjustKeyProviderWithoutInitialPush.

@Test
public void testNewEntityIncomingPushingAdjustKeyProviderWithoutInitialPush() throws IncompleteUpdateFoundException {
    final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate getInitialHighestAllowedKey() {
            return null;
        }

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

Example 13 with APushingHistoricalCacheAdjustKeyProvider

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

the class ATimeSeriesDBWithUnlimitedCacheTest method testNewEntityIncomingPushingAdjustKeyProviderWithoutPush.

@Test
public void testNewEntityIncomingPushingAdjustKeyProviderWithoutPush() throws IncompleteUpdateFoundException {
    final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {

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

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

Example 14 with APushingHistoricalCacheAdjustKeyProvider

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

the class ASegmentedTimeSeriesDBWithCacheTest method testNewEntityIncomingPushingAdjustKeyProvider.

@Test
public void testNewEntityIncomingPushingAdjustKeyProvider() throws IncompleteUpdateFoundException {
    final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {

        @Override
        protected FDate getInitialHighestAllowedKey() {
            return null;
        }

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

Example 15 with APushingHistoricalCacheAdjustKeyProvider

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

the class ASegmentedTimeSeriesDBWithCacheTest method testNewEntityIncomingPushingAdjustKeyProviderWithoutPush.

@Test
public void testNewEntityIncomingPushingAdjustKeyProviderWithoutPush() throws IncompleteUpdateFoundException {
    final APushingHistoricalCacheAdjustKeyProvider adjustKeyProvider = new APushingHistoricalCacheAdjustKeyProvider(cache) {

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

        @Override
        protected boolean isPullingRecursive() {
            return false;
        }
    };
    cache.setAdjustKeyProvider(adjustKeyProvider);
    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);
        }
    }
    adjustKeyProvider.pushHighestAllowedKey(newEntity);
    entities.add(newEntity);
    final FDate correctValue = cache.query().getValue(newEntity);
    Assertions.assertThat(correctValue).isEqualTo(newEntity);
}
Also used : APushingHistoricalCacheAdjustKeyProvider(de.invesdwin.util.collections.loadingcache.historical.key.APushingHistoricalCacheAdjustKeyProvider) ArrayList(java.util.ArrayList) 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)54 APushingHistoricalCacheAdjustKeyProvider (de.invesdwin.util.collections.loadingcache.historical.key.APushingHistoricalCacheAdjustKeyProvider)54 FDate (de.invesdwin.util.time.date.FDate)54 ArrayList (java.util.ArrayList)54 Test (org.junit.jupiter.api.Test)54 IEvaluateGenericFDate (de.invesdwin.util.math.expression.lambda.IEvaluateGenericFDate)6