File tree Expand file tree Collapse file tree
src/test/java/it/aboutbits/springboot/toolbox/validation/validator Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package it .aboutbits .springboot .toolbox .validation .validator ;
2+
3+ import it .aboutbits .springboot .toolbox .type .ScaledBigDecimal ;
4+ import jakarta .validation .Validation ;
5+ import jakarta .validation .ValidatorFactory ;
6+ import jakarta .validation .constraints .Positive ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import static org .assertj .core .api .Assertions .assertThat ;
10+
11+ public class BeanValidatorTest {
12+ private static final ValidatorFactory VALIDATOR_FACTORY = Validation .buildDefaultValidatorFactory ();
13+
14+ record TestBean (@ Positive ScaledBigDecimal value ) {
15+ }
16+
17+ @ Test
18+ void test () {
19+ var validator = VALIDATOR_FACTORY .getValidator ();
20+
21+ var instance = new TestBean (ScaledBigDecimal .ZERO );
22+
23+ var violations = validator .validate (instance );
24+
25+ assertThat (violations ).isNotEmpty ();
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments