Skip to content

Commit 9b695ca

Browse files
committed
完善测试
1 parent 53a6a7a commit 9b695ca

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-jakarta/src/test/java/modelengine/fitframework/validation/ValidationHandlerTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,4 +755,21 @@ void testRangeBigDecimalValidation() {
755755
ConstraintViolationException exception = invokeHandleMethod(method, new Object[] {new BigDecimal("5.5")});
756756
assertThat(exception.getMessage()).contains("需要在10和100之间");
757757
}
758+
759+
@Nested
760+
@DisplayName("测试 Locale 默认值为 null 时的情况")
761+
public class ValidationHandlerNullTest {
762+
@BeforeEach
763+
void setUp() {
764+
ValidationHandlerTest.this.handler.setLocale(null);
765+
}
766+
767+
@Test
768+
@DisplayName("测试@Null注解")
769+
void testNullValidation() {
770+
Method method = ReflectionUtils.getDeclaredMethod(ValidateService.class, "testNull", String.class);
771+
ConstraintViolationException exception = invokeHandleMethod(method, new Object[] {"not null"});
772+
assertThat(exception.getMessage()).isNotNull();
773+
}
774+
}
758775
}

framework/fit/java/fit-builtin/plugins/fit-validation-hibernate-javax/src/test/java/modelengine/fitframework/validation/ValidationHandlerTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,4 +757,21 @@ void testRangeBigDecimalValidation() {
757757
ConstraintViolationException exception = invokeHandleMethod(method, new Object[] {new BigDecimal("5.5")});
758758
assertThat(exception.getMessage()).contains("需要在10和100之间");
759759
}
760+
761+
@Nested
762+
@DisplayName("测试 Locale 默认值为 null 时的情况")
763+
public class ValidationHandlerNullTest {
764+
@BeforeEach
765+
void setUp() {
766+
ValidationHandlerTest.this.handler.setLocale(null);
767+
}
768+
769+
@Test
770+
@DisplayName("测试@Null注解")
771+
void testNullValidation() {
772+
Method method = ReflectionUtils.getDeclaredMethod(ValidateService.class, "testNull", String.class);
773+
ConstraintViolationException exception = invokeHandleMethod(method, new Object[] {"not null"});
774+
assertThat(exception.getMessage()).isNotNull();
775+
}
776+
}
760777
}

0 commit comments

Comments
 (0)