use of cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut in project today-infrastructure by TAKETODAY.
the class AnnotationMatchingPointcutTests method classLevelAndMethodLevelPointcuts.
@Test
public void classLevelAndMethodLevelPointcuts() {
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class, true);
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class, Qualifier.class);
assertThat(pointcut1.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut2.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut3.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut1.getClassFilter().toString()).contains(Qualifier.class.getName());
assertThat(pointcut1.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut2.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut3.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut1.getMethodMatcher().toString()).contains(Qualifier.class.getName());
assertThat(pointcut1).isEqualTo(pointcut2);
assertThat(pointcut1).isNotEqualTo(pointcut3);
assertThat(pointcut1.hashCode()).isEqualTo(pointcut2.hashCode());
// #1 and #3 have equivalent hash codes even though equals() returns false.
assertThat(pointcut1.hashCode()).isEqualTo(pointcut3.hashCode());
assertThat(pointcut1.toString()).isEqualTo(pointcut2.toString());
}
use of cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut in project today-infrastructure by TAKETODAY.
the class AnnotationMatchingPointcutTests method methodLevelPointcuts.
@Test
public void methodLevelPointcuts() {
Pointcut pointcut1 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
Pointcut pointcut2 = new AnnotationMatchingPointcut(null, Qualifier.class, true);
Pointcut pointcut3 = new AnnotationMatchingPointcut(null, Qualifier.class);
assertThat(pointcut1.getClassFilter().getClass().getSimpleName()).isEqualTo("AnnotationCandidateClassFilter");
assertThat(pointcut2.getClassFilter().getClass().getSimpleName()).isEqualTo("AnnotationCandidateClassFilter");
assertThat(pointcut3.getClassFilter().getClass().getSimpleName()).isEqualTo("AnnotationCandidateClassFilter");
assertThat(pointcut1.getClassFilter().toString()).contains(Qualifier.class.getName());
assertThat(pointcut1.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut2.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut3.getMethodMatcher().getClass()).isEqualTo(AnnotationMethodMatcher.class);
assertThat(pointcut1).isEqualTo(pointcut2);
assertThat(pointcut1).isNotEqualTo(pointcut3);
assertThat(pointcut1.hashCode()).isEqualTo(pointcut2.hashCode());
// #1 and #3 have equivalent hash codes even though equals() returns false.
assertThat(pointcut1.hashCode()).isEqualTo(pointcut3.hashCode());
assertThat(pointcut1.toString()).isEqualTo(pointcut2.toString());
}
use of cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut in project today-infrastructure by TAKETODAY.
the class AnnotationMatchingPointcutTests method classLevelPointcuts.
@Test
public void classLevelPointcuts() {
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, true);
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, true);
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class);
assertThat(pointcut1.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut2.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut3.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut1.getClassFilter().toString()).contains(Qualifier.class.getName());
assertThat(pointcut1.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut2.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut3.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut1).isEqualTo(pointcut2);
assertThat(pointcut1).isNotEqualTo(pointcut3);
assertThat(pointcut1.hashCode()).isEqualTo(pointcut2.hashCode());
// #1 and #3 have equivalent hash codes even though equals() returns false.
assertThat(pointcut1.hashCode()).isEqualTo(pointcut3.hashCode());
assertThat(pointcut1.toString()).isEqualTo(pointcut2.toString());
}
use of cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut in project today-framework by TAKETODAY.
the class AnnotationMatchingPointcutTests method classLevelPointcuts.
@Test
public void classLevelPointcuts() {
Pointcut pointcut1 = new AnnotationMatchingPointcut(Qualifier.class, true);
Pointcut pointcut2 = new AnnotationMatchingPointcut(Qualifier.class, true);
Pointcut pointcut3 = new AnnotationMatchingPointcut(Qualifier.class);
assertThat(pointcut1.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut2.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut3.getClassFilter().getClass()).isEqualTo(AnnotationClassFilter.class);
assertThat(pointcut1.getClassFilter().toString()).contains(Qualifier.class.getName());
assertThat(pointcut1.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut2.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut3.getMethodMatcher()).isEqualTo(MethodMatcher.TRUE);
assertThat(pointcut1).isEqualTo(pointcut2);
assertThat(pointcut1).isNotEqualTo(pointcut3);
assertThat(pointcut1.hashCode()).isEqualTo(pointcut2.hashCode());
// #1 and #3 have equivalent hash codes even though equals() returns false.
assertThat(pointcut1.hashCode()).isEqualTo(pointcut3.hashCode());
assertThat(pointcut1.toString()).isEqualTo(pointcut2.toString());
}
use of cn.taketoday.aop.support.annotation.AnnotationMatchingPointcut in project today-framework by TAKETODAY.
the class AsyncAnnotationAdvisor method buildPointcut.
/**
* Calculate a pointcut for the given async annotation types, if any.
*
* @param asyncAnnotationTypes the async annotation types to introspect
* @return the applicable Pointcut object, or {@code null} if none
*/
protected Pointcut buildPointcut(Set<Class<? extends Annotation>> asyncAnnotationTypes) {
ComposablePointcut result = null;
for (Class<? extends Annotation> asyncAnnotationType : asyncAnnotationTypes) {
Pointcut cpc = new AnnotationMatchingPointcut(asyncAnnotationType, true);
Pointcut mpc = new AnnotationMatchingPointcut(null, asyncAnnotationType, true);
if (result == null) {
result = new ComposablePointcut(cpc);
} else {
result.union(cpc);
}
result = result.union(mpc);
}
return (result != null ? result : Pointcut.TRUE);
}
Aggregations