private EvaluationContext createEvaluationContext(@Nullable Object result) { return evaluator.createEvaluationContext(this.caches, this.metadata.method, this.args, this.target, this.metadata.targetClass, this.metadata.targetMethod, result, beanFactory); }
private EvaluationContext createEvaluationContext(@Nullable Object result) { return evaluator.createEvaluationContext(this.caches, this.metadata.method, this.args, this.target, this.metadata.targetClass, this.metadata.targetMethod, result, beanFactory); }
private EvaluationContext createEvaluationContext(Object result, BeanFactory beanFactory) { AnnotatedClass target = new AnnotatedClass(); Method method = ReflectionUtils.findMethod( AnnotatedClass.class, "multipleCaching", Object.class, Object.class); Object[] args = new Object[] {new Object(), new Object()}; Collection<ConcurrentMapCache> caches = Collections.singleton(new ConcurrentMapCache("test")); return this.eval.createEvaluationContext( caches, method, args, target, target.getClass(), method, result, beanFactory); }
@Test public void testMultipleCachingEval() { AnnotatedClass target = new AnnotatedClass(); Method method = ReflectionUtils.findMethod( AnnotatedClass.class, "multipleCaching", Object.class, Object.class); Object[] args = new Object[] {new Object(), new Object()}; Collection<ConcurrentMapCache> caches = Collections.singleton(new ConcurrentMapCache("test")); EvaluationContext evalCtx = this.eval.createEvaluationContext(caches, method, args, target, target.getClass(), method, CacheOperationExpressionEvaluator.NO_RESULT, null); Collection<CacheOperation> ops = getOps("multipleCaching"); Iterator<CacheOperation> it = ops.iterator(); AnnotatedElementKey key = new AnnotatedElementKey(method, AnnotatedClass.class); Object keyA = this.eval.key(it.next().getKey(), key, evalCtx); Object keyB = this.eval.key(it.next().getKey(), key, evalCtx); assertEquals(args[0], keyA); assertEquals(args[1], keyB); }
protected boolean isConditionPassing(@Nullable Object result) { if (this.conditionPassing == null) { if (StringUtils.hasText(this.metadata.operation.getCondition())) { EvaluationContext evaluationContext = createEvaluationContext(result); this.conditionPassing = evaluator.condition(this.metadata.operation.getCondition(), this.metadata.methodKey, evaluationContext); } else { this.conditionPassing = true; } } return this.conditionPassing; }