CacheInvocationContextFactory { public static CacheInvocationContext<CacheRemove> createCacheRemoveInvocationContext(MetaHolder metaHolder) { Method method = metaHolder.getMethod(); if (method.isAnnotationPresent(CacheRemove.class)) { CacheRemove cacheRemove = method.getAnnotation(CacheRemove.class); MethodExecutionAction cacheKeyMethod = createCacheKeyAction(cacheRemove.cacheKeyMethod(), metaHolder); return new CacheInvocationContext<CacheRemove>(cacheRemove, cacheKeyMethod, metaHolder.getObj(), method, metaHolder.getArgs()); } return null; }  static CacheInvocationContext<CacheResult> createCacheResultInvocationContext(MetaHolder metaHolder); static CacheInvocationContext<CacheRemove> createCacheRemoveInvocationContext(MetaHolder metaHolder);  }
@Test public void testCreateCacheRemoveInvocationContext_givenMethodAnnotatedWithCacheRemove_shouldCreateCorrectCacheKeyInvocationContext() throws NoSuchMethodException { TestCacheClass testCacheClass = new TestCacheClass(); String param1 = "val_1"; MetaHolder metaHolder = MetaHolder.builder() .method(TestCacheClass.class.getMethod("cacheRemoveMethod", String.class)) .args(new Object[]{param1}) .obj(testCacheClass).build(); CacheInvocationContext<CacheRemove> context = CacheInvocationContextFactory.createCacheRemoveInvocationContext(metaHolder); assertNotNull(context.getKeyParameters()); assertEquals(1, context.getKeyParameters().size()); CacheInvocationParameter actual = context.getKeyParameters().get(0); assertEquals(String.class, actual.getRawType()); assertEquals(param1, actual.getValue()); assertEquals(0, actual.getPosition()); }