public class VCacheTestHelper extends Object
@Rule public EstablishWorkContext context = new EstablishWorkContext();
Example: vcacheFactory = VCachesTestHelper.getProxiedFactory(); cache = VCachesTestHelper.getExternalCache(factory, "TestDECache", String.class);; //it also builds expectations for cache creation calls ... doReturn(result(cachedString)).when(cache).get(eq(key), any(Supplier.class)); ... cache.put("key", value, PutPolicy.PUT_ALWAYS);
| Constructor and Description |
|---|
VCacheTestHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
cleanContext()
Clean up vcache context.
|
static <T extends Serializable> |
getExternalCache(VCacheFactory mockVcacheFactory,
String name,
Class<T> clazz)
Build
DirectExternalCache and set up mockito expectations for appropriate calls of VCacheFactory |
static <T extends Serializable> |
getExternalCache(VCacheFactory mockVcacheFactory,
String name,
Class<T> clazz,
ExternalCacheSettings settings)
Build
DirectExternalCache and set up mockito expectations for appropriate calls of VCacheFactory |
static VCacheFactory |
getFactory()
Build
VCacheFactory and set-up all necessary context. |
static VCacheFactory |
getFactory(Supplier<RequestContext> contextSupplier)
Build
VCacheFactory and set-up all necessary context. |
static <K,V> JvmCache<K,V> |
getJvmCache(VCacheFactory mockVcacheFactory,
String cacheName)
Build
JvmCache and set up mockito expectations for appropriate calls of VCacheFactory |
static <K,V> JvmCache<K,V> |
getJvmCache(VCacheFactory mockVcacheFactory,
String cacheName,
JvmCacheSettings settings)
Build
JvmCache and set up mockito expectations for appropriate calls of VCacheFactory |
static VCacheFactory |
getProxiedFactory()
Build
VCacheFactory and set-up all necessary context. |
static <T extends Serializable> |
getTransactionalCache(VCacheFactory mockVcacheFactory,
String name,
Class<T> clazz)
Build
TransactionalExternalCache and set up mockito expectations for appropriate calls of VCacheFactory |
static <T extends Serializable> |
getTransactionalCache(VCacheFactory mockVcacheFactory,
String name,
Class<T> clazz,
ExternalCacheSettings settings)
Build
TransactionalExternalCache and set up mockito expectations for appropriate calls of VCacheFactory |
public static VCacheFactory getFactory()
VCacheFactory and set-up all necessary context. Please don't forget to call
cleanContext() after tests to clean up vcache context.VCacheFactory suitable for testing.public static VCacheFactory getFactory(Supplier<RequestContext> contextSupplier)
VCacheFactory and set-up all necessary context. Please don't forget to call
cleanContext() after tests to clean up vcache context.contextSupplier - the context supplier to be used when creating caches.VCacheFactory suitable for testing.public static VCacheFactory getProxiedFactory()
VCacheFactory and set-up all necessary context. Please don't forget to call
cleanContext() after tests to clean up vcache context.VCacheFactory suitable for testing. Returned value is mockito proxied object, so can be used
to build test expectations.public static <T extends Serializable> DirectExternalCache<T> getExternalCache(VCacheFactory mockVcacheFactory, String name, Class<T> clazz)
DirectExternalCache and set up mockito expectations for appropriate calls of VCacheFactoryT - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactoryname - name of the cacheclazz - class of cached objectsDirectExternalCache proxied by mockito.public static <T extends Serializable> DirectExternalCache<T> getExternalCache(VCacheFactory mockVcacheFactory, String name, Class<T> clazz, ExternalCacheSettings settings)
DirectExternalCache and set up mockito expectations for appropriate calls of VCacheFactoryT - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactoryname - name of the cacheclazz - class of cached objectssettings - cache settingsDirectExternalCache proxied by mockito.public static <K,V> JvmCache<K,V> getJvmCache(VCacheFactory mockVcacheFactory, String cacheName)
JvmCache and set up mockito expectations for appropriate calls of VCacheFactoryK - type of cache keysV - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactorycacheName - name of the cacheJvmCache proxied by mockito.public static <K,V> JvmCache<K,V> getJvmCache(VCacheFactory mockVcacheFactory, String cacheName, JvmCacheSettings settings)
JvmCache and set up mockito expectations for appropriate calls of VCacheFactoryK - type of cache keysV - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactorycacheName - name of the cachesettings - cache settingsJvmCache proxied by mockito.public static <T extends Serializable> TransactionalExternalCache<T> getTransactionalCache(VCacheFactory mockVcacheFactory, String name, Class<T> clazz)
TransactionalExternalCache and set up mockito expectations for appropriate calls of VCacheFactoryT - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactoryname - name of the cacheclazz - class of cached objectsTransactionalExternalCache proxied by mockito.public static <T extends Serializable> TransactionalExternalCache<T> getTransactionalCache(VCacheFactory mockVcacheFactory, String name, Class<T> clazz, ExternalCacheSettings settings)
TransactionalExternalCache and set up mockito expectations for appropriate calls of VCacheFactoryT - type of cached objectsmockVcacheFactory - mockito proxied or mocked VCacheFactoryname - name of the cacheclazz - class of cached objectssettings - cache settingsTransactionalExternalCache proxied by mockito.public static void cleanContext()
Copyright © 2019 Atlassian. All rights reserved.