Search in sources :

Example 1 with SimpleValueWrapper

use of org.springframework.cache.support.SimpleValueWrapper in project CzechIdMng by bcvsolutions.

the class DefaultSysProvisioningBreakConfigService method getCacheProcessedItems.

@Override
public SysProvisioningBreakItems getCacheProcessedItems(UUID systemId) {
    SimpleValueWrapper cachedValueWrapper = (SimpleValueWrapper) this.getCache().get(systemId);
    if (cachedValueWrapper == null) {
        return new SysProvisioningBreakItems();
    }
    SysProvisioningBreakItems cache = (SysProvisioningBreakItems) cachedValueWrapper.get();
    if (cache == null) {
        return new SysProvisioningBreakItems();
    }
    return cache;
}
Also used : SimpleValueWrapper(org.springframework.cache.support.SimpleValueWrapper) SysProvisioningBreakItems(eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems)

Example 2 with SimpleValueWrapper

use of org.springframework.cache.support.SimpleValueWrapper in project spring-framework by spring-projects.

the class CacheErrorHandlerTests method getAndPutFail.

@Test
public void getAndPutFail() {
    UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
    willThrow(exception).given(this.cache).get(0L);
    // Update of the cache will fail as well
    willThrow(exception).given(this.cache).put(0L, 0L);
    Object counter = this.simpleService.get(0L);
    willReturn(new SimpleValueWrapper(2L)).given(this.cache).get(0L);
    Object counter2 = this.simpleService.get(0L);
    Object counter3 = this.simpleService.get(0L);
    assertThat(counter2).isNotSameAs(counter);
    assertThat(counter3).isEqualTo(counter2);
}
Also used : SimpleValueWrapper(org.springframework.cache.support.SimpleValueWrapper) Test(org.junit.jupiter.api.Test)

Example 3 with SimpleValueWrapper

use of org.springframework.cache.support.SimpleValueWrapper in project POC by rajadilipkolli.

the class CustomCacheErrorHandlerTest method getAndPutFail.

@Test
public void getAndPutFail() {
    final UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on get");
    willThrow(exception).given(this.cache).get(0L);
    // Update of the cache will
    willThrow(exception).given(this.cache).put(0L, 0L);
    // fail as well
    final Object counter = this.simpleService.get(0L);
    willReturn(new SimpleValueWrapper(2L)).given(this.cache).get(0L);
    final Object counter2 = this.simpleService.get(0L);
    final Object counter3 = this.simpleService.get(0L);
    assertThat(counter2).isEqualTo(counter3);
    assertThat(counter).isNotEqualTo(counter2);
}
Also used : SimpleValueWrapper(org.springframework.cache.support.SimpleValueWrapper) AbstractMongoDBRedisIntegrationTest(com.poc.mongodbredisintegration.AbstractMongoDBRedisIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

SimpleValueWrapper (org.springframework.cache.support.SimpleValueWrapper)3 Test (org.junit.jupiter.api.Test)2 AbstractMongoDBRedisIntegrationTest (com.poc.mongodbredisintegration.AbstractMongoDBRedisIntegrationTest)1 SysProvisioningBreakItems (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakItems)1