Rename SearchStrategy.EXHAUSTIVE to TYPE_HIERARCHY

Rename `SearchStrategy.EXHAUSTIVE` from `MergedAnnotations` to
`SearchStrategy.TYPE_HIERARCHY`

See gh-23378
This commit is contained in:
Phillip Webb
2019-07-31 13:46:25 +01:00
parent e6f86c5c75
commit a6021cc968
13 changed files with 196 additions and 182 deletions

View File

@@ -179,43 +179,43 @@ public class AnnotationsScannerTests {
}
@Test
public void exhaustiveStrategyOnClassWhenNotAnnoatedScansNone() {
public void typeHierarchyStrategyOnClassWhenNotAnnoatedScansNone() {
Class<?> source = WithNoAnnotations.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).isEmpty();
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty();
}
@Test
public void exhaustiveStrategyOnClassScansAnnotations() {
public void typeHierarchyStrategyOnClassScansAnnotations() {
Class<?> source = WithSingleAnnotation.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void exhaustiveStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
public void typeHierarchyStrategyOnClassWhenMultipleAnnotationsScansAnnotations() {
Class<?> source = WithMultipleAnnotations.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void exhaustiveStrategyOnClassWhenHasSuperclassScansSuperclass() {
public void typeHierarchyStrategyOnClassWhenHasSuperclassScansSuperclass() {
Class<?> source = WithSingleSuperclass.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void exhaustiveStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
public void typeHierarchyStrategyOnClassWhenHasInterfaceDoesNotIncludeInterfaces() {
Class<?> source = WithSingleInterface.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void exhaustiveStrategyOnClassHierarchyScansInCorrectOrder() {
public void typeHierarchyStrategyOnClassHierarchyScansInCorrectOrder() {
Class<?> source = WithHierarchy.class;
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
"2:TestAnnotation6", "3:TestAnnotation2", "3:TestInheritedAnnotation2",
"4:TestAnnotation3", "5:TestAnnotation4");
@@ -346,61 +346,61 @@ public class AnnotationsScannerTests {
}
@Test
public void exhaustiveStrategyOnMethodWhenNotAnnoatedScansNone() {
public void typeHierarchyStrategyOnMethodWhenNotAnnoatedScansNone() {
Method source = methodFrom(WithNoAnnotations.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).isEmpty();
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).isEmpty();
}
@Test
public void exhaustiveStrategyOnMethodScansAnnotations() {
public void typeHierarchyStrategyOnMethodScansAnnotations() {
Method source = methodFrom(WithSingleAnnotation.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void exhaustiveStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
public void typeHierarchyStrategyOnMethodWhenMultipleAnnotationsScansAnnotations() {
Method source = methodFrom(WithMultipleAnnotations.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "0:TestAnnotation2");
}
@Test
public void exhaustiveStrategyOnMethodWhenHasSuperclassScansSuperclass() {
public void typeHierarchyStrategyOnMethodWhenHasSuperclassScansSuperclass() {
Method source = methodFrom(WithSingleSuperclass.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void exhaustiveStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
public void typeHierarchyStrategyOnMethodWhenHasInterfaceDoesNotIncludeInterfaces() {
Method source = methodFrom(WithSingleInterface.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2", "1:TestInheritedAnnotation2");
}
@Test
public void exhaustiveStrategyOnMethodHierarchyScansInCorrectOrder() {
public void typeHierarchyStrategyOnMethodHierarchyScansInCorrectOrder() {
Method source = methodFrom(WithHierarchy.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation5", "1:TestInheritedAnnotation5",
"2:TestAnnotation6", "3:TestAnnotation2", "3:TestInheritedAnnotation2",
"4:TestAnnotation3", "5:TestAnnotation4");
}
@Test
public void exhaustiveStrategyOnBridgeMethodScansAnnotations() throws Exception {
public void typeHierarchyStrategyOnBridgeMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", Object.class);
assertThat(source.isBridge()).isTrue();
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2");
}
@Test
public void exhaustiveStrategyOnBridgedMethodScansAnnotations() throws Exception {
public void typeHierarchyStrategyOnBridgedMethodScansAnnotations() throws Exception {
Method source = BridgedMethod.class.getDeclaredMethod("method", String.class);
assertThat(source.isBridge()).isFalse();
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2");
}
@@ -421,43 +421,43 @@ public class AnnotationsScannerTests {
}
@Test
public void exhaustiveStrategyOnMethodWithIgnorablesScansAnnotations()
public void typeHierarchyStrategyOnMethodWithIgnorablesScansAnnotations()
throws Exception {
Method source = methodFrom(Ignoreable.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void exhaustiveStrategyOnMethodWithMultipleCandidatesScansAnnotations()
public void typeHierarchyStrategyOnMethodWithMultipleCandidatesScansAnnotations()
throws Exception {
Method source = methodFrom(MultipleMethods.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void exhaustiveStrategyOnMethodWithGenericParameterOverrideScansAnnotations()
public void typeHierarchyStrategyOnMethodWithGenericParameterOverrideScansAnnotations()
throws Exception {
Method source = ReflectionUtils.findMethod(GenericOverride.class, "method",
String.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1", "1:TestAnnotation2");
}
@Test
public void exhaustiveStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations()
public void typeHierarchyStrategyOnMethodWithGenericParameterNonOverrideScansAnnotations()
throws Exception {
Method source = ReflectionUtils.findMethod(GenericNonOverride.class, "method",
StringBuilder.class);
assertThat(scan(source, SearchStrategy.EXHAUSTIVE)).containsExactly(
assertThat(scan(source, SearchStrategy.TYPE_HIERARCHY)).containsExactly(
"0:TestAnnotation1");
}
@Test
public void scanWhenProcessorReturnsFromDoWithAggregateExitsEarly() {
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.EXHAUSTIVE, new AnnotationsProcessor<Object, String>() {
SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor<Object, String>() {
@Override
@Nullable
@@ -480,7 +480,7 @@ public class AnnotationsScannerTests {
public void scanWhenProcessorReturnsFromDoWithAnnotationsExitsEarly() {
List<Integer> indexes = new ArrayList<>();
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.EXHAUSTIVE,
SearchStrategy.TYPE_HIERARCHY,
(context, aggregateIndex, source, annotations) -> {
indexes.add(aggregateIndex);
return "";
@@ -492,7 +492,7 @@ public class AnnotationsScannerTests {
@Test
public void scanWhenProcessorHasFinishMethodUsesFinishResult() {
String result = AnnotationsScanner.scan(this, WithSingleSuperclass.class,
SearchStrategy.EXHAUSTIVE, new AnnotationsProcessor<Object, String>() {
SearchStrategy.TYPE_HIERARCHY, new AnnotationsProcessor<Object, String>() {
@Override
@Nullable

View File

@@ -105,70 +105,70 @@ public class MergedAnnotationsComposedOnSingleAnnotatedElementTests {
}
@Test
public void exhaustiveStrategyMultipleComposedAnnotationsOnClass() {
assertExhaustiveStrategyBehavior(MultipleComposedCachesClass.class);
public void typeHierarchyStrategyMultipleComposedAnnotationsOnClass() {
assertTypeHierarchyStrategyBehavior(MultipleComposedCachesClass.class);
}
@Test
public void exhaustiveStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
assertExhaustiveStrategyBehavior(SubMultipleComposedCachesClass.class);
public void typeHierarchyStrategyMultipleInheritedComposedAnnotationsOnSuperclass() {
assertTypeHierarchyStrategyBehavior(SubMultipleComposedCachesClass.class);
}
@Test
public void exhaustiveStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnClass() {
MergedAnnotations annotations = MergedAnnotations.from(
MultipleNoninheritedComposedCachesClass.class, SearchStrategy.EXHAUSTIVE);
MultipleNoninheritedComposedCachesClass.class, SearchStrategy.TYPE_HIERARCHY);
assertThat(stream(annotations, "value")).containsExactly("noninheritedCache1",
"noninheritedCache2");
}
@Test
public void exhaustiveStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
public void typeHierarchyStrategyMultipleNoninheritedComposedAnnotationsOnSuperclass() {
MergedAnnotations annotations = MergedAnnotations.from(
SubMultipleNoninheritedComposedCachesClass.class,
SearchStrategy.EXHAUSTIVE);
SearchStrategy.TYPE_HIERARCHY);
assertThat(stream(annotations, "value")).containsExactly("noninheritedCache1",
"noninheritedCache2");
}
@Test
public void exhaustiveStrategyComposedPlusLocalAnnotationsOnClass() {
assertExhaustiveStrategyBehavior(ComposedPlusLocalCachesClass.class);
public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnClass() {
assertTypeHierarchyStrategyBehavior(ComposedPlusLocalCachesClass.class);
}
@Test
public void exhaustiveStrategyMultipleComposedAnnotationsOnInterface() {
assertExhaustiveStrategyBehavior(MultipleComposedCachesOnInterfaceClass.class);
public void typeHierarchyStrategyMultipleComposedAnnotationsOnInterface() {
assertTypeHierarchyStrategyBehavior(MultipleComposedCachesOnInterfaceClass.class);
}
@Test
public void exhaustiveStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() {
assertExhaustiveStrategyBehavior(
public void typeHierarchyStrategyComposedCacheOnInterfaceAndLocalCacheOnClass() {
assertTypeHierarchyStrategyBehavior(
ComposedCacheOnInterfaceAndLocalCacheClass.class);
}
@Test
public void exhaustiveStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
assertExhaustiveStrategyBehavior(
public void typeHierarchyStrategyMultipleComposedAnnotationsOnMethod() throws Exception {
assertTypeHierarchyStrategyBehavior(
getClass().getDeclaredMethod("multipleComposedCachesMethod"));
}
@Test
public void exhaustiveStrategyComposedPlusLocalAnnotationsOnMethod()
public void typeHierarchyStrategyComposedPlusLocalAnnotationsOnMethod()
throws Exception {
assertExhaustiveStrategyBehavior(
assertTypeHierarchyStrategyBehavior(
getClass().getDeclaredMethod("composedPlusLocalCachesMethod"));
}
@Test
public void exhaustiveStrategyMultipleComposedAnnotationsOnBridgeMethod()
public void typeHierarchyStrategyMultipleComposedAnnotationsOnBridgeMethod()
throws Exception {
assertExhaustiveStrategyBehavior(getBridgeMethod());
assertTypeHierarchyStrategyBehavior(getBridgeMethod());
}
private void assertExhaustiveStrategyBehavior(AnnotatedElement element) {
private void assertTypeHierarchyStrategyBehavior(AnnotatedElement element) {
MergedAnnotations annotations = MergedAnnotations.from(element,
SearchStrategy.EXHAUSTIVE);
SearchStrategy.TYPE_HIERARCHY);
assertThat(stream(annotations, "key")).containsExactly("fooKey", "barKey");
assertThat(stream(annotations, "value")).containsExactly("fooCache", "barCache");
}

View File

@@ -135,89 +135,89 @@ public class MergedAnnotationsRepeatableAnnotationTests {
}
@Test
public void exhaustiveWhenNonRepeatableThrowsException() {
public void typeHierarchyWhenNonRepeatableThrowsException() {
assertThatIllegalArgumentException().isThrownBy(() ->
getAnnotations(null, NonRepeatable.class, SearchStrategy.EXHAUSTIVE, getClass()))
getAnnotations(null, NonRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass()))
.satisfies(this::nonRepeatableRequirements);
}
@Test
public void exhaustiveWhenContainerMissingValueAttributeThrowsException() {
public void typeHierarchyWhenContainerMissingValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.EXHAUSTIVE, getClass()))
SearchStrategy.TYPE_HIERARCHY, getClass()))
.satisfies(this::missingValueAttributeRequirements);
}
@Test
public void exhaustiveWhenWhenNonArrayValueAttributeThrowsException() {
public void typeHierarchyWhenWhenNonArrayValueAttributeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class,
SearchStrategy.EXHAUSTIVE, getClass()))
SearchStrategy.TYPE_HIERARCHY, getClass()))
.satisfies(this::nonArrayValueAttributeRequirements);
}
@Test
public void exhaustiveWhenWrongComponentTypeThrowsException() {
public void typeHierarchyWhenWrongComponentTypeThrowsException() {
assertThatAnnotationConfigurationException().isThrownBy(() ->
getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class,
InvalidRepeatable.class, SearchStrategy.EXHAUSTIVE, getClass()))
InvalidRepeatable.class, SearchStrategy.TYPE_HIERARCHY, getClass()))
.satisfies(this::wrongComponentTypeRequirements);
}
@Test
public void exhaustiveWhenOnClassReturnsAnnotations() {
public void typeHierarchyWhenOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.EXHAUSTIVE, RepeatableClass.class);
SearchStrategy.TYPE_HIERARCHY, RepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
"C");
}
@Test
public void exhaustiveWhenWhenOnSuperclassReturnsAnnotations() {
public void typeHierarchyWhenWhenOnSuperclassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.EXHAUSTIVE, SubRepeatableClass.class);
SearchStrategy.TYPE_HIERARCHY, SubRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
"C");
}
@Test
public void exhaustiveWhenComposedOnClassReturnsAnnotations() {
public void typeHierarchyWhenComposedOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.EXHAUSTIVE, ComposedRepeatableClass.class);
SearchStrategy.TYPE_HIERARCHY, ComposedRepeatableClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
"C");
}
@Test
public void exhaustiveWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
public void typeHierarchyWhenComposedMixedWithContainerOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.EXHAUSTIVE,
SearchStrategy.TYPE_HIERARCHY,
ComposedRepeatableMixedWithContainerClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
"C");
}
@Test
public void exhaustiveWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
public void typeHierarchyWhenComposedContainerForRepeatableOnClassReturnsAnnotations() {
Set<PeteRepeat> annotations = getAnnotations(null, PeteRepeat.class,
SearchStrategy.EXHAUSTIVE, ComposedContainerClass.class);
SearchStrategy.TYPE_HIERARCHY, ComposedContainerClass.class);
assertThat(annotations.stream().map(PeteRepeat::value)).containsExactly("A", "B",
"C");
}
@Test
public void exhaustiveAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnClassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.EXHAUSTIVE, NoninheritedRepeatableClass.class);
SearchStrategy.TYPE_HIERARCHY, NoninheritedRepeatableClass.class);
assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A",
"B", "C");
}
@Test
public void exhaustiveAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
public void typeHierarchyAnnotationsWhenNoninheritedComposedRepeatableOnSuperclassReturnsAnnotations() {
Set<Noninherited> annotations = getAnnotations(null, Noninherited.class,
SearchStrategy.EXHAUSTIVE, SubNoninheritedRepeatableClass.class);
SearchStrategy.TYPE_HIERARCHY, SubNoninheritedRepeatableClass.class);
assertThat(annotations.stream().map(Noninherited::value)).containsExactly("A",
"B", "C");
}

View File

@@ -459,93 +459,93 @@ public class MergedAnnotationsTests {
}
@Test
public void getWithExhaustiveFromInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
InheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(0);
}
@Test
public void getWithExhaustiveFromSubInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromSubInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@Test
public void getWithExhaustiveFromSubSubInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromSubSubInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(2);
}
@Test
public void getWithExhaustiveFromNonInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
NonInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Order.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(0);
}
@Test
public void getWithExhaustiveFromSubNonInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromSubNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubNonInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Order.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@Test
public void getWithExhaustiveFromSubSubNonInheritedAnnotationInterface() {
public void getWithTypeHierarchyFromSubSubNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubNonInheritedAnnotationInterface.class,
SearchStrategy.EXHAUSTIVE).get(Order.class);
SearchStrategy.TYPE_HIERARCHY).get(Order.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(2);
}
@Test
public void getWithExhaustiveInheritedFromInterfaceMethod()
public void getWithTypeHierarchyInheritedFromInterfaceMethod()
throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod(
"handleFromInterface");
MergedAnnotation<?> annotation = MergedAnnotations.from(method,
SearchStrategy.EXHAUSTIVE).get(Order.class);
SearchStrategy.TYPE_HIERARCHY).get(Order.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@Test
public void getWithExhaustiveInheritedFromAbstractMethod()
public void getWithTypeHierarchyInheritedFromAbstractMethod()
throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod("handle");
MergedAnnotation<?> annotation = MergedAnnotations.from(method,
SearchStrategy.EXHAUSTIVE).get(Transactional.class);
SearchStrategy.TYPE_HIERARCHY).get(Transactional.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@Test
public void getWithExhaustiveInheritedFromBridgedMethod()
public void getWithTypeHierarchyInheritedFromBridgedMethod()
throws NoSuchMethodException {
Method method = ConcreteClassWithInheritedAnnotation.class.getMethod(
"handleParameterized", String.class);
MergedAnnotation<?> annotation = MergedAnnotations.from(method,
SearchStrategy.EXHAUSTIVE).get(Transactional.class);
SearchStrategy.TYPE_HIERARCHY).get(Transactional.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@Test
public void getWithExhaustiveFromBridgeMethod() {
public void getWithTypeHierarchyFromBridgeMethod() {
List<Method> methods = new ArrayList<>();
ReflectionUtils.doWithLocalMethods(StringGenericParameter.class, method -> {
if ("getFor".equals(method.getName())) {
@@ -561,23 +561,23 @@ public class MergedAnnotationsTests {
assertThat(bridgeMethod.isBridge()).isTrue();
assertThat(bridgedMethod.isBridge()).isFalse();
MergedAnnotation<?> annotation = MergedAnnotations.from(bridgeMethod,
SearchStrategy.EXHAUSTIVE).get(Order.class);
SearchStrategy.TYPE_HIERARCHY).get(Order.class);
assertThat(annotation.isPresent()).isTrue();
assertThat(annotation.getAggregateIndex()).isEqualTo(0);
}
@Test
public void getWithExhaustiveFromClassWithMetaAndLocalTxConfig() {
public void getWithTypeHierarchyFromClassWithMetaAndLocalTxConfig() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
MetaAndLocalTxConfigClass.class, SearchStrategy.EXHAUSTIVE).get(
MetaAndLocalTxConfigClass.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.getString("qualifier")).isEqualTo("localTxMgr");
}
@Test
public void getWithExhaustiveFromClassWithAttributeAliasesInTargetAnnotation() {
public void getWithTypeHierarchyFromClassWithAttributeAliasesInTargetAnnotation() {
MergedAnnotation<AliasedTransactional> mergedAnnotation = MergedAnnotations.from(
AliasedTransactionalComponentClass.class, SearchStrategy.EXHAUSTIVE).get(
AliasedTransactionalComponentClass.class, SearchStrategy.TYPE_HIERARCHY).get(
AliasedTransactional.class);
AliasedTransactional synthesizedAnnotation = mergedAnnotation.synthesize();
String qualifier = "aliasForQualifier";
@@ -588,8 +588,8 @@ public class MergedAnnotationsTests {
}
@Test
public void getWithExhaustiveFromClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() {
MergedAnnotation<?> annotation = testGetWithExhaustive(
public void getWithTypeHierarchyFromClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() {
MergedAnnotation<?> annotation = testGetWithTypeHierarchy(
TestComponentScanClass.class, "com.example.app.test");
MergedAnnotation<Filter>[] excludeFilters = annotation.getAnnotationArray(
"excludeFilters", Filter.class);
@@ -599,37 +599,37 @@ public class MergedAnnotationsTests {
}
@Test
public void getWithExhaustiveFromClassWithBothAttributesOfAnAliasPairDeclared() {
testGetWithExhaustive(ComponentScanWithBasePackagesAndValueAliasClass.class,
public void getWithTypeHierarchyFromClassWithBothAttributesOfAnAliasPairDeclared() {
testGetWithTypeHierarchy(ComponentScanWithBasePackagesAndValueAliasClass.class,
"com.example.app.test");
}
@Test
public void getWithExhaustiveWithSingleElementOverridingAnArrayViaConvention() {
testGetWithExhaustive(ConventionBasedSinglePackageComponentScanClass.class,
public void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaConvention() {
testGetWithTypeHierarchy(ConventionBasedSinglePackageComponentScanClass.class,
"com.example.app.test");
}
@Test
public void getWithExhaustiveWithSingleElementOverridingAnArrayViaAliasFor() {
testGetWithExhaustive(AliasForBasedSinglePackageComponentScanClass.class,
public void getWithTypeHierarchyWithSingleElementOverridingAnArrayViaAliasFor() {
testGetWithTypeHierarchy(AliasForBasedSinglePackageComponentScanClass.class,
"com.example.app.test");
}
private MergedAnnotation<?> testGetWithExhaustive(Class<?> element,
private MergedAnnotation<?> testGetWithTypeHierarchy(Class<?> element,
String... expected) {
MergedAnnotation<?> annotation = MergedAnnotations.from(element,
SearchStrategy.EXHAUSTIVE).get(ComponentScan.class);
SearchStrategy.TYPE_HIERARCHY).get(ComponentScan.class);
assertThat(annotation.getStringArray("value")).containsExactly(expected);
assertThat(annotation.getStringArray("basePackages")).containsExactly(expected);
return annotation;
}
@Test
public void getWithExhaustiveWhenMultipleMetaAnnotationsHaveClashingAttributeNames() {
public void getWithTypeHierarchyWhenMultipleMetaAnnotationsHaveClashingAttributeNames() {
MergedAnnotations annotations = MergedAnnotations.from(
AliasedComposedContextConfigurationAndTestPropertySourceClass.class,
SearchStrategy.EXHAUSTIVE);
SearchStrategy.TYPE_HIERARCHY);
MergedAnnotation<?> contextConfig = annotations.get(ContextConfiguration.class);
assertThat(contextConfig.getStringArray("locations")).containsExactly("test.xml");
assertThat(contextConfig.getStringArray("value")).containsExactly("test.xml");
@@ -641,9 +641,9 @@ public class MergedAnnotationsTests {
}
@Test
public void getWithExhaustiveWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() {
public void getWithTypeHierarchyWithLocalAliasesThatConflictWithAttributesInMetaAnnotationByConvention() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SpringApplicationConfigurationClass.class, SearchStrategy.EXHAUSTIVE).get(
SpringApplicationConfigurationClass.class, SearchStrategy.TYPE_HIERARCHY).get(
ContextConfiguration.class);
assertThat(annotation.getStringArray("locations")).isEmpty();
assertThat(annotation.getStringArray("value")).isEmpty();
@@ -651,22 +651,22 @@ public class MergedAnnotationsTests {
}
@Test
public void getWithExhaustiveOnMethodWithSingleElementOverridingAnArrayViaConvention() throws Exception {
testGetWithExhaustiveWebMapping(
public void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaConvention() throws Exception {
testGetWithTypeHierarchyWebMapping(
WebController.class.getMethod("postMappedWithPathAttribute"));
}
@Test
public void getWithExhaustiveOnMethodWithSingleElementOverridingAnArrayViaAliasFor() throws Exception {
testGetWithExhaustiveWebMapping(
public void getWithTypeHierarchyOnMethodWithSingleElementOverridingAnArrayViaAliasFor() throws Exception {
testGetWithTypeHierarchyWebMapping(
WebController.class.getMethod("getMappedWithValueAttribute"));
testGetWithExhaustiveWebMapping(
testGetWithTypeHierarchyWebMapping(
WebController.class.getMethod("getMappedWithPathAttribute"));
}
private void testGetWithExhaustiveWebMapping(AnnotatedElement element) throws ArrayComparisonFailure {
private void testGetWithTypeHierarchyWebMapping(AnnotatedElement element) throws ArrayComparisonFailure {
MergedAnnotation<?> annotation = MergedAnnotations.from(element,
SearchStrategy.EXHAUSTIVE).get(RequestMapping.class);
SearchStrategy.TYPE_HIERARCHY).get(RequestMapping.class);
assertThat(annotation.getStringArray("value")).containsExactly("/test");
assertThat(annotation.getStringArray("path")).containsExactly("/test");
}
@@ -686,9 +686,9 @@ public class MergedAnnotationsTests {
}
@Test
public void streamExhaustiveFromClassWithInterface() throws Exception {
public void streamTypeHierarchyFromClassWithInterface() throws Exception {
Method method = TransactionalServiceImpl.class.getMethod("doIt");
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).stream(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).stream(
Transactional.class)).hasSize(1);
}
@@ -698,7 +698,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNotNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
0);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -708,7 +708,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
-1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -718,7 +718,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(1);
}
@@ -729,7 +729,7 @@ public class MergedAnnotationsTests {
assertThat(
MergedAnnotations.from(method).get(Component.class).getDistance()).isEqualTo(
2);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Component.class).getDistance()).isEqualTo(2);
}
@@ -739,7 +739,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNotNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
0);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -749,7 +749,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(1);
}
@@ -759,7 +759,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
-1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -769,7 +769,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
-1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(-1);
}
@@ -781,7 +781,7 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
-1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
boolean runningInEclipse = Arrays.stream(
new Exception().getStackTrace()).anyMatch(
@@ -800,7 +800,7 @@ public class MergedAnnotationsTests {
}
assertThat(MergedAnnotations.from(method).get(
Transactional.class).getDistance()).isEqualTo(0);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class).getDistance()).isEqualTo(0);
}
@@ -812,19 +812,19 @@ public class MergedAnnotationsTests {
assertThat(method.getAnnotation(Order.class)).isNull();
assertThat(MergedAnnotations.from(method).get(Order.class).getDistance()).isEqualTo(
-1);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
assertThat(method.getAnnotation(Transactional.class)).isNotNull();
assertThat(MergedAnnotations.from(method).get(
Transactional.class).getDistance()).isEqualTo(0);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class).getDistance()).isEqualTo(0);
}
@Test
public void getFromMethodWithInterface() throws Exception {
Method method = ImplementsInterfaceWithAnnotatedMethod.class.getMethod("foo");
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -832,7 +832,7 @@ public class MergedAnnotationsTests {
public void getFromMethodWithGenericInterface() throws Exception {
Method method = ImplementsInterfaceWithGenericAnnotatedMethod.class.getMethod(
"foo", String.class);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -840,7 +840,7 @@ public class MergedAnnotationsTests {
public void getFromMethodWithGenericSuperclass() throws Exception {
Method method = ExtendsBaseClassWithGenericAnnotatedMethod.class.getMethod("foo",
String.class);
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -848,7 +848,7 @@ public class MergedAnnotationsTests {
public void getFromMethodWithInterfaceOnSuper() throws Exception {
Method method = SubOfImplementsInterfaceWithAnnotatedMethod.class.getMethod(
"foo");
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -857,7 +857,7 @@ public class MergedAnnotationsTests {
throws Exception {
Method method = SubOfAbstractImplementsInterfaceWithAnnotatedMethod.class.getMethod(
"foo");
assertThat(MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE).get(
assertThat(MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY).get(
Order.class).getDistance()).isEqualTo(0);
}
@@ -865,14 +865,14 @@ public class MergedAnnotationsTests {
public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverAnnotationsOnInterfaces() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
ClassWithLocalMetaAnnotationAndMetaAnnotatedInterface.class,
SearchStrategy.EXHAUSTIVE).get(Component.class);
SearchStrategy.TYPE_HIERARCHY).get(Component.class);
assertThat(annotation.getString("value")).isEqualTo("meta2");
}
@Test
public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedAnnotations() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubClassWithInheritedAnnotation.class, SearchStrategy.EXHAUSTIVE).get(
SubSubClassWithInheritedAnnotation.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.getBoolean("readOnly")).isTrue();
}
@@ -881,14 +881,14 @@ public class MergedAnnotationsTests {
public void getDirectFromClassFavorsMoreLocallyDeclaredComposedAnnotationsOverInheritedComposedAnnotations() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubClassWithInheritedMetaAnnotation.class,
SearchStrategy.EXHAUSTIVE).get(Component.class);
SearchStrategy.TYPE_HIERARCHY).get(Component.class);
assertThat(annotation.getString("value")).isEqualTo("meta2");
}
@Test
public void getDirectFromClassgetDirectFromClassMetaMetaAnnotatedClass() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
MetaMetaAnnotatedClass.class, SearchStrategy.EXHAUSTIVE).get(
MetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(
Component.class);
assertThat(annotation.getString("value")).isEqualTo("meta2");
}
@@ -896,7 +896,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithMetaMetaMetaAnnotatedClass() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
MetaMetaMetaAnnotatedClass.class, SearchStrategy.EXHAUSTIVE).get(
MetaMetaMetaAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(
Component.class);
assertThat(annotation.getString("value")).isEqualTo("meta2");
}
@@ -905,14 +905,14 @@ public class MergedAnnotationsTests {
public void getDirectFromClassWithAnnotatedClassWithMissingTargetMetaAnnotation() {
// TransactionalClass is NOT annotated or meta-annotated with @Component
MergedAnnotation<?> annotation = MergedAnnotations.from(TransactionalClass.class,
SearchStrategy.EXHAUSTIVE).get(Component.class);
SearchStrategy.TYPE_HIERARCHY).get(Component.class);
assertThat(annotation.isPresent()).isFalse();
}
@Test
public void getDirectFromClassWithMetaCycleAnnotatedClassWithMissingTargetMetaAnnotation() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
MetaCycleAnnotatedClass.class, SearchStrategy.EXHAUSTIVE).get(
MetaCycleAnnotatedClass.class, SearchStrategy.TYPE_HIERARCHY).get(
Component.class);
assertThat(annotation.isPresent()).isFalse();
}
@@ -920,7 +920,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
InheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
InheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(0);
}
@@ -928,7 +928,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithSubInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@@ -936,7 +936,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithSubSubInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubSubInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Transactional.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(2);
}
@@ -944,7 +944,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
NonInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
NonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Order.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(0);
}
@@ -952,7 +952,7 @@ public class MergedAnnotationsTests {
@Test
public void getDirectFromClassWithSubNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubNonInheritedAnnotationInterface.class, SearchStrategy.EXHAUSTIVE).get(
SubNonInheritedAnnotationInterface.class, SearchStrategy.TYPE_HIERARCHY).get(
Order.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(1);
}
@@ -961,7 +961,7 @@ public class MergedAnnotationsTests {
public void getDirectFromClassWithSubSubNonInheritedAnnotationInterface() {
MergedAnnotation<?> annotation = MergedAnnotations.from(
SubSubNonInheritedAnnotationInterface.class,
SearchStrategy.EXHAUSTIVE).get(Order.class);
SearchStrategy.TYPE_HIERARCHY).get(Order.class);
assertThat(annotation.getAggregateIndex()).isEqualTo(2);
}
@@ -1225,7 +1225,7 @@ public class MergedAnnotationsTests {
@Test
public void getValueFromAnnotation() throws Exception {
Method method = TransactionalStringGeneric.class.getMethod("something", Object.class);
MergedAnnotation<?> annotation = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE)
MergedAnnotation<?> annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY)
.get(Order.class);
assertThat(annotation.getInt("value")).isEqualTo(1);
}
@@ -1244,7 +1244,7 @@ public class MergedAnnotationsTests {
@Test
public void getDefaultValueFromAnnotation() throws Exception {
Method method = TransactionalStringGeneric.class.getMethod("something", Object.class);
MergedAnnotation<Order> annotation = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE)
MergedAnnotation<Order> annotation = MergedAnnotations.from(method, SearchStrategy.TYPE_HIERARCHY)
.get(Order.class);
assertThat(annotation.getDefaultValue("value")).contains(Ordered.LOWEST_PRECEDENCE);
}
@@ -1271,7 +1271,7 @@ public class MergedAnnotationsTests {
public void getRepeatableDeclaredOnMethod() throws Exception {
Method method = InterfaceWithRepeated.class.getMethod("foo");
Stream<MergedAnnotation<MyRepeatable>> annotations = MergedAnnotations.from(
method, SearchStrategy.EXHAUSTIVE).stream(MyRepeatable.class);
method, SearchStrategy.TYPE_HIERARCHY).stream(MyRepeatable.class);
Stream<String> values = annotations.map(
annotation -> annotation.getString("value"));
assertThat(values).containsExactly("A", "B", "C", "meta1");
@@ -1282,7 +1282,7 @@ public class MergedAnnotationsTests {
RepeatableContainers containers = RepeatableContainers.of(
BrokenContextConfiguration.class, BrokenHierarchy.class);
assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
MergedAnnotations.from(BrokenHierarchyClass.class, SearchStrategy.EXHAUSTIVE, containers,
MergedAnnotations.from(BrokenHierarchyClass.class, SearchStrategy.TYPE_HIERARCHY, containers,
AnnotationFilter.PLAIN).get(BrokenHierarchy.class))
.withMessageStartingWith("Attribute 'value' in")
.withMessageContaining(BrokenContextConfiguration.class.getName())