use of cn.taketoday.cache.interceptor.CacheOperation in project today-infrastructure by TAKETODAY.
the class AnnotationCacheOperationSourceTests method multipleComposedAnnotations.
@Test
public void multipleComposedAnnotations() {
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleComposed", 4);
Iterator<CacheOperation> it = ops.iterator();
CacheOperation cacheOperation = it.next();
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("directly declared"));
assertThat(cacheOperation.getKey()).isEqualTo("");
cacheOperation = it.next();
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("composedCache"));
assertThat(cacheOperation.getKey()).isEqualTo("composedKey");
cacheOperation = it.next();
assertThat(cacheOperation).isInstanceOf(CacheableOperation.class);
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("foo"));
assertThat(cacheOperation.getKey()).isEqualTo("");
cacheOperation = it.next();
assertThat(cacheOperation).isInstanceOf(CacheEvictOperation.class);
assertThat(cacheOperation.getCacheNames()).isEqualTo(Collections.singleton("composedCacheEvict"));
assertThat(cacheOperation.getKey()).isEqualTo("composedEvictionKey");
}
use of cn.taketoday.cache.interceptor.CacheOperation in project today-infrastructure by TAKETODAY.
the class AnnotationCacheOperationSourceTests method customKeyGeneratorInherited.
@Test
public void customKeyGeneratorInherited() {
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "customKeyGeneratorInherited", 1);
CacheOperation cacheOperation = ops.iterator().next();
assertThat(cacheOperation.getKeyGenerator()).as("Custom key generator not set").isEqualTo("custom");
}
use of cn.taketoday.cache.interceptor.CacheOperation in project today-infrastructure by TAKETODAY.
the class AnnotationCacheOperationSourceTests method cacheConfigFromInterface.
@Test
public void cacheConfigFromInterface() {
Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheConfig");
CacheOperation cacheOperation = ops.iterator().next();
assertSharedConfig(cacheOperation, "", "", "", "myCache");
}
use of cn.taketoday.cache.interceptor.CacheOperation in project today-infrastructure by TAKETODAY.
the class AnnotationCacheOperationSourceTests method validateNoCacheIsValid.
@Test
public void validateNoCacheIsValid() {
// Valid as a CacheResolver might return the cache names to use with other info
Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "noCacheNameSpecified");
CacheOperation cacheOperation = ops.iterator().next();
assertThat(cacheOperation.getCacheNames()).as("cache names set must not be null").isNotNull();
assertThat(cacheOperation.getCacheNames().size()).as("no cache names specified").isEqualTo(0);
}
use of cn.taketoday.cache.interceptor.CacheOperation in project today-infrastructure by TAKETODAY.
the class AnnotationCacheOperationSourceTests method customClassLevelWithCustomCacheName.
@Test
public void customClassLevelWithCustomCacheName() {
Collection<CacheOperation> ops = getOps(AnnotatedClassWithCustomDefault.class, "methodLevelCacheName", 1);
CacheOperation cacheOperation = ops.iterator().next();
assertSharedConfig(cacheOperation, "classKeyGenerator", "", "classCacheResolver", "custom");
}
Aggregations