Add MergedAnnotation.getRoot() method
Update `MergedAnnotation` with a `getRoot()` method that allows the root direct annotation to be retrieved easily. Closes gh-22818
This commit is contained in:
@@ -154,6 +154,22 @@ public class MergedAnnotationsTests {
|
||||
.isEqualTo(ComposedTransactionalComponent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRootWhenNotDirect() {
|
||||
MergedAnnotations annotations = MergedAnnotations.from(ComposedTransactionalComponentClass.class);
|
||||
MergedAnnotation<?> annotation = annotations.get(TransactionalComponent.class);
|
||||
assertThat(annotation.getDepth()).isGreaterThan(0);
|
||||
assertThat(annotation.getRoot().getType()).isEqualTo(ComposedTransactionalComponent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRootWhenDirect() {
|
||||
MergedAnnotations annotations = MergedAnnotations.from(ComposedTransactionalComponentClass.class);
|
||||
MergedAnnotation<?> annotation = annotations.get(ComposedTransactionalComponent.class);
|
||||
assertThat(annotation.getDepth()).isEqualTo(0);
|
||||
assertThat(annotation.getRoot()).isSameAs(annotation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void collectMultiValueMapFromNonAnnotatedClass() {
|
||||
MultiValueMap<String, Object> map = MergedAnnotations.from(
|
||||
|
||||
@@ -78,6 +78,11 @@ public class MissingMergedAnnotationTests {
|
||||
assertThat(this.missing.getParent()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRootReturnsEmptyAnnotation() {
|
||||
assertThat(this.missing.getRoot()).isSameAs(this.missing);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasNonDefaultValueThrowsNoSuchElementException() {
|
||||
assertThatNoSuchElementException().isThrownBy(
|
||||
|
||||
Reference in New Issue
Block a user