test_class.file: guja-core/src/test/java/com/wadpam/guja/cache/annotations/CacheRemoveEntityMethodInterceptorTest.java
test_class.identifier: CacheRemoveEntityMethodInterceptorTest
test_class.superclass: extends AbstractCacheMethodInterceptorTest
test_case.body: @Test
    public void testInvoke() throws Exception {
      final String parentKey = null;
  
      expect(mockDao.put(parentKey, 1L, "1")).andReturn(1L).once();
      mockDao.delete(parentKey, 1L);
      expect(mockDao.get(parentKey, 1L)).andReturn(null).times(1);
      expect(mockDao.put(parentKey, 1L, "1")).andReturn(1L).once();
  
      replay(mockDao);
  
      Long id = dao.put(parentKey, 1L, "1");
      assertTrue(id.equals(1L));
  
      String value = dao.get(parentKey, 1L);
      assertTrue("1".equals(value));
  
      dao.delete(parentKey, 1L);
  
      value = dao.get(parentKey, 1L);
      assertTrue(null == value);
  
      value = dao.get(parentKey, 1L);
      assertTrue(null == value);
  
      id = dao.put(parentKey, 1L, "1");
      assertTrue(id.equals(1L));
  
      value = dao.get(parentKey, 1L);
      assertTrue("1".equals(value));
  
    }
test_case.class_method_signature: CacheRemoveEntityMethodInterceptorTest.testInvoke()
test_case.full_signature: @Test public void testInvoke()
test_case.identifier: testInvoke
test_case.invocations: once andReturn expect put delete times andReturn expect get once andReturn expect put replay put assertTrue equals get assertTrue equals delete get assertTrue get assertTrue put assertTrue equals get assertTrue equals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInvoke()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(CacheRemoveEntityMethodInterceptor.class)
focal_class.modifier: static final
focal_class.original_string: static final Logger LOGGER = LoggerFactory.getLogger(CacheRemoveEntityMethodInterceptor.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.file: guja-core/src/main/java/com/wadpam/guja/cache/annotations/CacheRemoveEntityMethodInterceptor.java
focal_class.identifier: CacheRemoveEntityMethodInterceptor
focal_class.class_method_signature: CacheRemoveEntityMethodInterceptor.CacheRemoveEntityMethodInterceptor(Provider<CacheResolver> cacheResolverProvider, Provider<CacheKeyGenerator> defaultCacheKeyGeneratorProvider)
focal_class.full_signature: @Inject public  CacheRemoveEntityMethodInterceptor(Provider<CacheResolver> cacheResolverProvider, Provider<CacheKeyGenerator> defaultCacheKeyGeneratorProvider)
focal_class.identifier: CacheRemoveEntityMethodInterceptor
focal_class.modifiers: @Inject public
focal_class.parameters: (Provider<CacheResolver> cacheResolverProvider, Provider<CacheKeyGenerator> defaultCacheKeyGeneratorProvider)
focal_class.signature:  CacheRemoveEntityMethodInterceptor(Provider<CacheResolver> cacheResolverProvider, Provider<CacheKeyGenerator> defaultCacheKeyGeneratorProvider)
focal_class.class_method_signature: CacheRemoveEntityMethodInterceptor.invoke(MethodInvocation methodInvocation)
focal_class.full_signature: @Override public Object invoke(MethodInvocation methodInvocation)
focal_class.identifier: invoke
focal_class.modifiers: @Override public
focal_class.parameters: (MethodInvocation methodInvocation)
focal_class.return: Object
focal_class.signature: Object invoke(MethodInvocation methodInvocation)
focal_class.class_method_signature: CacheRemoveEntityMethodInterceptor.invalidateCache(GeneratedCacheKey key, Cache<GeneratedCacheKey, Optional<?>> cache)
focal_class.full_signature: private static void invalidateCache(GeneratedCacheKey key, Cache<GeneratedCacheKey, Optional<?>> cache)
focal_class.identifier: invalidateCache
focal_class.modifiers: private static
focal_class.parameters: (GeneratedCacheKey key, Cache<GeneratedCacheKey, Optional<?>> cache)
focal_class.return: void
focal_class.signature: void invalidateCache(GeneratedCacheKey key, Cache<GeneratedCacheKey, Optional<?>> cache)
focal_class.superclass: extends AbstractCacheMethodInterceptor
focal_method.body: @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
  
      final Method method = methodInvocation.getMethod();
      final CacheRemove annotation = method.getAnnotation(CacheRemove.class);
      checkNotNull(annotation);
      final CacheKeyInvocationContext<CacheRemove> context = new GuiceCacheKeyInvocationContext<>(methodInvocation, annotation, annotation.cacheName());
  
      LOGGER.trace("Cache REMOVE {}", context.getMethod().getName());
  
      // get cache
      final Cache<GeneratedCacheKey, Optional<?>> cache = getCache(context, methodInvocation);
  
      // get key
      final CacheKeyGenerator keyGenerator = getCacheKeyGenerator(methodInvocation, annotation.cacheKeyGenerator());
      final GeneratedCacheKey key = keyGenerator.generateCacheKey(context);
  
      if (!annotation.afterInvocation()) {
        invalidateCache(key, cache);
      }
  
      final Object result = methodInvocation.proceed();
  
      if (annotation.afterInvocation()) {
        invalidateCache(key, cache);
      }
  
      return result;
    }
focal_method.class_method_signature: CacheRemoveEntityMethodInterceptor.invoke(MethodInvocation methodInvocation)
focal_method.full_signature: @Override public Object invoke(MethodInvocation methodInvocation)
focal_method.identifier: invoke
focal_method.invocations: getMethod getAnnotation checkNotNull cacheName trace getName getMethod getCache getCacheKeyGenerator cacheKeyGenerator generateCacheKey afterInvocation invalidateCache proceed afterInvocation invalidateCache
focal_method.modifiers: @Override public
focal_method.parameters: (MethodInvocation methodInvocation)
focal_method.return: Object
focal_method.signature: Object invoke(MethodInvocation methodInvocation)