File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/test/java/test/org/javawebstack/validator Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ package test .org .javawebstack .validator ;
2+
3+ import org .javawebstack .abstractdata .AbstractMapper ;
4+ import org .javawebstack .validator .Rule ;
5+ import org .javawebstack .validator .ValidationContext ;
6+ import org .javawebstack .validator .Validator ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import java .util .Random ;
10+
11+ import static org .junit .jupiter .api .Assertions .assertFalse ;
12+ import static org .junit .jupiter .api .Assertions .assertTrue ;
13+
14+ public class EmailRuleTest {
15+
16+ @ Test
17+ public void testSimpleRequiredRule (){
18+ Validator validator = Validator .getValidator (TestObject1 .class );
19+ TestObject1 test = new TestObject1 ();
20+ test .email = "Test" ;
21+ assertFalse (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
22+ test .email = "info@test.de" ;
23+ assertTrue (validator .validate (new ValidationContext (), new AbstractMapper ().toAbstract (test )).isValid ());
24+ }
25+
26+ private static class TestObject1 {
27+ @ Rule ("email" )
28+ String email ;
29+ }
30+
31+ }
You can’t perform that action at this time.
0 commit comments