Skip to content

Commit 848ed65

Browse files
committed
Add test for JSR-350 @nonnull
Closes gh-24647
1 parent 67d1f35 commit 848ed65

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/OperationMethodParameterTests.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class OperationMethodParameterTests {
4545
private Method exampleMetaJsr305 = ReflectionUtils.findMethod(getClass(), "exampleMetaJsr305", String.class,
4646
String.class);
4747

48+
private Method exampleJsr305NonNull = ReflectionUtils.findMethod(getClass(), "exampleJsr305NonNull", String.class,
49+
String.class);
50+
4851
@Test
4952
void getNameShouldReturnName() {
5053
OperationMethodParameter parameter = new OperationMethodParameter("name", this.example.getParameters()[0]);
@@ -83,16 +86,22 @@ void isMandatoryWhenJsrMetaNullableAnnotationShouldReturnFalse() {
8386
assertThat(parameter.isMandatory()).isFalse();
8487
}
8588

86-
void example(String one, @Nullable String two) {
89+
public void isMandatoryWhenJsrNonnullAnnotationShouldReturnTrue() {
90+
OperationMethodParameter parameter = new OperationMethodParameter("name",
91+
this.exampleJsr305NonNull.getParameters()[1]);
92+
assertThat(parameter.isMandatory()).isTrue();
93+
}
8794

95+
void example(String one, @Nullable String two) {
8896
}
8997

9098
void exampleJsr305(String one, @javax.annotation.Nullable String two) {
91-
9299
}
93100

94101
void exampleMetaJsr305(String one, @MetaNullable String two) {
102+
}
95103

104+
void exampleJsr305NonNull(String one, @javax.annotation.Nonnull String two) {
96105
}
97106

98107
@TypeQualifier

0 commit comments

Comments
 (0)