test_class.declarator: EXPIRATION = 100
test_class.modifier: private static final
test_class.original_string: private static final int EXPIRATION = 100;
test_class.type: int
test_class.var_name: EXPIRATION
test_class.declarator: expectedValue
test_class.modifier: private final
test_class.original_string: private final Object expectedValue;
test_class.type: Object
test_class.var_name: expectedValue
test_class.file: simple-spring-memcached/src/test/java/com/google/code/ssm/aop/counter/ReadCounterFromCacheAdviceTest.java
test_class.identifier: ReadCounterFromCacheAdviceTest
test_class.superclass: extends AbstractCounterTest<ReadCounterFromCacheAdvice>
test_case.body: @Test
      public void validReadCounterCacheHit() throws Throwable {
          Assume.assumeTrue(isValid);
  
          Long value = 100L;
  
          when(cache.getCounter(eq(cacheKey))).thenReturn(value);
  
          assertEquals(value.intValue(), ((Number) advice.readCounter(pjp)).intValue());
  
          verify(cache).getCounter(eq(cacheKey));
          verify(cache, never()).incr(anyString(), anyInt(), anyLong(), anyInt());
          verify(pjp, never()).proceed();
      }
test_case.class_method_signature: ReadCounterFromCacheAdviceTest.validReadCounterCacheHit()
test_case.full_signature: @Test public void validReadCounterCacheHit()
test_case.identifier: validReadCounterCacheHit
test_case.invocations: assumeTrue thenReturn when getCounter eq assertEquals intValue intValue readCounter getCounter verify eq incr verify never anyString anyInt anyLong anyInt proceed verify never
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void validReadCounterCacheHit()
focal_class.declarator: LOG = LoggerFactory.getLogger(ReadCounterFromCacheAdvice.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(ReadCounterFromCacheAdvice.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.file: simple-spring-memcached/src/main/java/com/google/code/ssm/aop/counter/ReadCounterFromCacheAdvice.java
focal_class.identifier: ReadCounterFromCacheAdvice
focal_class.class_method_signature: ReadCounterFromCacheAdvice.readSingleCounter()
focal_class.full_signature: @Pointcut("@annotation(com.google.code.ssm.api.counter.ReadCounterFromCache)") public void readSingleCounter()
focal_class.identifier: readSingleCounter
focal_class.modifiers: @Pointcut("@annotation(com.google.code.ssm.api.counter.ReadCounterFromCache)") public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void readSingleCounter()
focal_class.class_method_signature: ReadCounterFromCacheAdvice.readCounter(final ProceedingJoinPoint pjp)
focal_class.full_signature: @Around("readSingleCounter()") public Object readCounter(final ProceedingJoinPoint pjp)
focal_class.identifier: readCounter
focal_class.modifiers: @Around("readSingleCounter()") public
focal_class.parameters: (final ProceedingJoinPoint pjp)
focal_class.return: Object
focal_class.signature: Object readCounter(final ProceedingJoinPoint pjp)
focal_class.class_method_signature: ReadCounterFromCacheAdvice.verifyMethodSignature(final Method methodToCache)
focal_class.full_signature: protected void verifyMethodSignature(final Method methodToCache)
focal_class.identifier: verifyMethodSignature
focal_class.modifiers: protected
focal_class.parameters: (final Method methodToCache)
focal_class.return: void
focal_class.signature: void verifyMethodSignature(final Method methodToCache)
focal_class.class_method_signature: ReadCounterFromCacheAdvice.convertResult(final Method method, final long result)
focal_class.full_signature: protected Number convertResult(final Method method, final long result)
focal_class.identifier: convertResult
focal_class.modifiers: protected
focal_class.parameters: (final Method method, final long result)
focal_class.return: Number
focal_class.signature: Number convertResult(final Method method, final long result)
focal_class.class_method_signature: ReadCounterFromCacheAdvice.getLogger()
focal_class.full_signature: @Override protected Logger getLogger()
focal_class.identifier: getLogger
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: Logger
focal_class.signature: Logger getLogger()
focal_class.superclass: extends CounterInCacheBase
focal_method.body: @Around("readSingleCounter()")
      public Object readCounter(final ProceedingJoinPoint pjp) throws Throwable {
          if (isDisabled()) {
              getLogger().info("Cache disabled");
              return pjp.proceed();
          }
  
          // This is injected caching. If anything goes wrong in the caching, LOG
          // the crap outta it, but do not let it surface up past the AOP injection itself.
          // It will be invoked only if underlying method completes successfully.
          String cacheKey = null;
          ReadCounterFromCache annotation;
          AnnotationData data;
          try {
              Method methodToCache = getCacheBase().getMethodToCache(pjp, ReadCounterFromCache.class);
              verifyMethodSignature(methodToCache);
              annotation = methodToCache.getAnnotation(ReadCounterFromCache.class);
              data = AnnotationDataBuilder.buildAnnotationData(annotation, ReadCounterFromCache.class, methodToCache);
              cacheKey = getCacheBase().getCacheKeyBuilder().getCacheKey(data, pjp.getArgs(), methodToCache.toString());
              Long result = getCacheBase().getCache(data).getCounter(cacheKey);
  
              if (result != null) {
                  getLogger().debug("Cache hit.");
                  return convertResult(methodToCache, result);
              }
          } catch (Exception ex) {
              warn(ex, "Caching on method %s and key [%s] aborted due to an error.", pjp.toShortString(), cacheKey);
              return pjp.proceed();
          }
  
          final Object result = pjp.proceed();
  
          // This is injected caching. If anything goes wrong in the caching, LOG
          // the crap outta it, but do not let it surface up past the AOP injection itself.
          try {
              if (checkData(result, pjp)) {
                  long value = ((Number) result).longValue();
                  // tricky way to update counter
                  getCacheBase().getCache(data).incr(cacheKey, 0, value, annotation.expiration());
              }
          } catch (Exception ex) {
              warn(ex, "Caching on method %s and key [%s] aborted due to an error.", pjp.toShortString(), cacheKey);
          }
          return result;
      }
focal_method.class_method_signature: ReadCounterFromCacheAdvice.readCounter(final ProceedingJoinPoint pjp)
focal_method.full_signature: @Around("readSingleCounter()") public Object readCounter(final ProceedingJoinPoint pjp)
focal_method.identifier: readCounter
focal_method.invocations: isDisabled info getLogger proceed getMethodToCache getCacheBase verifyMethodSignature getAnnotation buildAnnotationData getCacheKey getCacheKeyBuilder getCacheBase getArgs toString getCounter getCache getCacheBase debug getLogger convertResult warn toShortString proceed proceed checkData longValue incr getCache getCacheBase expiration warn toShortString
focal_method.modifiers: @Around("readSingleCounter()") public
focal_method.parameters: (final ProceedingJoinPoint pjp)
focal_method.return: Object
focal_method.signature: Object readCounter(final ProceedingJoinPoint pjp)