Skip to content

Instantly share code, notes, and snippets.

@jzheaux
Created January 8, 2025 23:25
public class ConflictTests {
@Test
void tryToNoticeConflictingAnnotations() throws Exception {
Conflicting c = new Conflicting();
Method m = c.getClass().getDeclaredMethod("method");
List<MergedAnnotation<PreAuthorize>> found = MergedAnnotations
.from(m, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY, RepeatableContainers.none())
.stream(PreAuthorize.class).filter(MergedAnnotation::isPresent).toList();
assertThat(found).hasSize(2);
assertThat(found.get(0).getAggregateIndex())
.isEqualTo(found.get(1).getAggregateIndex());
}
private interface A {
@PreAuthorize("A")
String method();
}
private interface B {
@PreAuthorize("B")
String method();
}
private static class Conflicting implements A, B {
@Override
public String method() {
return "ok";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment