### Question:
InjectVariableELResolver extends ELResolver { @Override public Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] paramValues) { if (base == null || method == null) { return null; } List<Method> methods = findMethodWithInjections(base.getClass(), method.toString()); if (paramTypes == null) { paramTypes = getTypesFromValues(paramValues); } for(Method m : methods) { Class<?>[] newParamTypes = processParamTypes(m.getParameters(), paramTypes); if(newParamTypes == null) { continue; } Object[] newParams = processParams(context, m.getParameters(), paramValues); if(newParams == null) { continue; } try { return delegate.invoke(context, base, method, newParamTypes, newParams); } catch (MethodNotFoundException e) { } } return null; }  @Override Object getValue(ELContext context, Object base, Object property); @Override Object invoke(ELContext context, Object base, Object method, Class<?>[] paramTypes, Object[] paramValues); @Override Class<?> getType(ELContext context, Object base, Object property); @Override void setValue(ELContext context, Object base, Object property, Object value); @Override boolean isReadOnly(ELContext context, Object base, Object property); @Override Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base); @Override Class<?> getCommonPropertyType(ELContext context, Object base);  }### Answer:
@Test public void callWithoutInject() { TestTask task = spy(new TestTask()); Object method = "callWithInject"; Class<?>[] paramTypes = null; Object[] paramValues = null; resolver.invoke(elContext, task, method, paramTypes, paramValues); verify(task, times(0)).callWithInject(); }
@Test public void callWithInjectOnlyInjectedVars() { TestTask task = spy(new TestTask()); Object method = "callWithInject1"; Class<?>[] paramTypes = null; Object[] paramValues = null; resolver.invoke(elContext, task, method, paramTypes, paramValues); verify(task, times(1)).callWithInject1(any(ExecutionContext.class)); }
@Test public void callWithInject() { TestTask task = spy(new TestTask()); Object method = "callWithInject1"; Class<?>[] paramTypes = null; Object[] paramValues = {"xxxx"}; resolver.invoke(elContext, task, method, paramTypes, paramValues); verify(task, times(1)).callWithInject1(any(ExecutionContext.class), eq("xxxx")); }
@Test public void callWithInject2() { TestTask task = spy(new TestTask()); Object method = "callWithInject2"; Class<?>[] paramTypes = null; Object[] paramValues = {"xxxx"}; mockVariables("injectedVar", "another-var"); resolver.invoke(elContext, task, method, paramTypes, paramValues); verify(task, times(1)).callWithInject2(any(ExecutionContext.class), eq("another-var"), eq("xxxx")); }