1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.fieldlevel;
17
18 import org.junit.Test;
19 import org.kuali.rice.kns.datadictionary.validation.fieldlevel.EmailAddressValidationPattern;
20 import org.kuali.rice.krad.test.KRADTestCase;
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25
26
27
28
29
30 public class EmailAddressValidationPatternTest extends KRADTestCase {
31 private EmailAddressValidationPattern pattern;
32
33 @Override
34 public void setUp() throws Exception {
35 super.setUp();
36
37 pattern = new EmailAddressValidationPattern();
38 }
39
40
41 @Test public final void testMatches_valid1() {
42 assertTrue(pattern.matches("ww5@a.b.c.org"));
43 }
44
45 @Test public final void testMatches_valid2() {
46 assertTrue(pattern.matches("something.else@a2.com"));
47 }
48
49 @Test public final void testMatches_valid3() {
50 assertTrue(pattern.matches("something_else@something.else.com"));
51 }
52
53 @Test public final void testMatches_valid4() {
54 assertTrue(pattern.matches("something-else@et-tu.com"));
55 }
56
57
58 @Test public final void testMatches_invalid1() {
59 assertFalse(pattern.matches("a"));
60 }
61
62 @Test public final void testMatches_invalid2() {
63 assertFalse(pattern.matches("@a.b.c.org"));
64 }
65
66 @Test public final void testMatches_invalid3() {
67 assertFalse(pattern.matches("1@a.b.c.org"));
68 }
69
70 @Test public final void testMatches_invalid4() {
71 assertFalse(pattern.matches("1@org"));
72 }
73
74 @Test public final void testMatches_invalid5() {
75 assertFalse(pattern.matches("1@a"));
76 }
77
78 @Test public final void testMatches_invalid6() {
79 assertFalse(pattern.matches(".@a.org"));
80 }
81
82 @Test public final void testMatches_invalid7() {
83 assertFalse(pattern.matches("_@a.org"));
84 }
85
86 @Test public final void testMatches_invalid8() {
87 assertFalse(pattern.matches("something@a.o-rg"));
88 }
89 }