CacheBase implements ApplicationContextAware, InitializingBean { @SuppressWarnings("unchecked") public <T> T getUpdateData(final AnnotationData data, final Method method, final Object[] args, final Object returnValue) throws Exception { return data.isReturnDataIndex() ? (T) returnValue : (T) Utils.getMethodArg(data.getDataIndex(), args, method.toString()); }  @Override void afterPropertiesSet(); @Override void setApplicationContext(final ApplicationContext applicationContext); void setCacheKeyBuilder(final CacheKeyBuilder cacheKeyBuilder); CacheKeyBuilder getCacheKeyBuilder(); BridgeMethodMappingStore getBridgeMethodMappingStore(); void setBridgeMethodMappingStore(final BridgeMethodMappingStore bridgeMethodMappingStore); Cache getCache(final AnnotationData data); boolean isCacheDisabled(); Method getMethodToCache(final JoinPoint jp, final Class<T> annotationClass); @SuppressWarnings("unchecked") T getUpdateData(final AnnotationData data, final Method method, final Object[] args, final Object returnValue); static final String DISABLE_CACHE_PROPERTY; }
@Test public void getUpdateData() throws Exception { AnnotationData annotationData = new AnnotationData(); annotationData.setDataIndex(-1); Object entity = new Object(); Object result = cut.getUpdateData(annotationData, null, null, entity); assertSame(entity, result); annotationData = new AnnotationData(); annotationData.setReturnDataIndex(true); result = cut.getUpdateData(annotationData, null, null, entity); assertSame(entity, result); annotationData = new AnnotationData(); annotationData.setDataIndex(1); Method method = UpdateData.class.getMethod("update", new Class[] { int.class, Object.class }); result = cut.getUpdateData(annotationData, method, new Object[] { 144, entity }, entity); assertSame(entity, result); }