From 848ed65f5b94da6c611f18dcd8fe15819e1664ab Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 6 Jan 2021 12:04:58 -0800 Subject: [PATCH] Add test for JSR-350 @Nonnull Closes gh-24647 --- .../reflect/OperationMethodParameterTests.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java index d633ce948be4..98186555043b 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java @@ -45,6 +45,9 @@ class OperationMethodParameterTests { private Method exampleMetaJsr305 = ReflectionUtils.findMethod(getClass(), "exampleMetaJsr305", String.class, String.class); + private Method exampleJsr305NonNull = ReflectionUtils.findMethod(getClass(), "exampleJsr305NonNull", String.class, + String.class); + @Test void getNameShouldReturnName() { OperationMethodParameter parameter = new OperationMethodParameter("name", this.example.getParameters()[0]); @@ -83,16 +86,22 @@ void isMandatoryWhenJsrMetaNullableAnnotationShouldReturnFalse() { assertThat(parameter.isMandatory()).isFalse(); } - void example(String one, @Nullable String two) { + public void isMandatoryWhenJsrNonnullAnnotationShouldReturnTrue() { + OperationMethodParameter parameter = new OperationMethodParameter("name", + this.exampleJsr305NonNull.getParameters()[1]); + assertThat(parameter.isMandatory()).isTrue(); + } + void example(String one, @Nullable String two) { } void exampleJsr305(String one, @javax.annotation.Nullable String two) { - } void exampleMetaJsr305(String one, @MetaNullable String two) { + } + void exampleJsr305NonNull(String one, @javax.annotation.Nonnull String two) { } @TypeQualifier