@Test public void testFlippableMethodEnabled() throws Throwable { setCurrentMethod(flippableMethod); when(featureService.getFeatureState(eq("test"))).thenReturn(FeatureState.ENABLED); assertEquals("result", aspect.aroundFlippableMethods(pjp, flipAnnotation)); }
@Around(value="anyMethod() && @annotation(flip)", argNames="flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for(int i=0;i<paramAnnotations.length;i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } }
FlipAbstractAspect { @Around(value="anyMethod() && @annotation(flip)", argNames="flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for(int i=0;i<paramAnnotations.length;i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } } }
FlipAbstractAspect { @Around(value="anyMethod() && @annotation(flip)", argNames="flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for(int i=0;i<paramAnnotations.length;i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } }  }
FlipAbstractAspect { @Around(value="anyMethod() && @annotation(flip)", argNames="flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for(int i=0;i<paramAnnotations.length;i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } }  FeatureService getFeatureService(); ConvertersHandler getConvertersHandler(); ValueExpressionEvaluator getValueExpressionEvaluator(); String getDefaultValue(); void setDefaultValue(String defaultValue); @Pointcut("execution(* *(..))") void anyMethod(); @Around(value="anyMethod() && @annotation(flip)", argNames="flip") Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip); Object aroundFlippableMethods(ProceedingJoinPoint pjp); }
FlipAbstractAspect { @Around(value="anyMethod() && @annotation(flip)", argNames="flip") public Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip) throws Throwable { MethodSignature methodSignature = (MethodSignature)pjp.getSignature(); Method method = methodSignature.getMethod(); if (isFeatureEnabled(flip.feature())) { Annotation[][] paramAnnotations = method.getParameterAnnotations(); Object[] params = pjp.getArgs(); Class[] paramTypes = method.getParameterTypes(); for(int i=0;i<paramAnnotations.length;i++) { FlipParam flipParam = findFlipParamAnnoattion(paramAnnotations[i]); if (!isFeatureEnabled(flipParam.feature())) { params[i] = getProcessedDisabledValue(paramTypes[i], flipParam.disabledValue(), pjp.getThis()); } } return pjp.proceed(params); } else { return getProcessedDisabledValue(method.getReturnType(), flip.disabledValue(), pjp.getThis()); } }  FeatureService getFeatureService(); ConvertersHandler getConvertersHandler(); ValueExpressionEvaluator getValueExpressionEvaluator(); String getDefaultValue(); void setDefaultValue(String defaultValue); @Pointcut("execution(* *(..))") void anyMethod(); @Around(value="anyMethod() && @annotation(flip)", argNames="flip") Object aroundFlippableMethods(ProceedingJoinPoint pjp, Flippable flip); Object aroundFlippableMethods(ProceedingJoinPoint pjp);  }