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.ZipcodeValidationPattern;
20 import org.kuali.test.KRADTestCase;
21
22 import static org.junit.Assert.assertFalse;
23 import static org.junit.Assert.assertTrue;
24
25
26
27
28
29
30
31
32 public class ZipcodeValidationPatternTest extends KRADTestCase {
33 private ZipcodeValidationPattern pattern;
34
35 @Override
36 public void setUp() throws Exception {
37 super.setUp();
38
39 pattern = new ZipcodeValidationPattern();
40 }
41
42
43 @Test public final void testMatches_5digit_valid() {
44 assertTrue(pattern.matches("12345"));
45 }
46
47 @Test public final void testMatches_9digit_valid() {
48 assertTrue(pattern.matches("12345-1234"));
49 }
50
51 @Test public final void testMatches_invalid1() {
52 assertFalse(pattern.matches("123456"));
53 }
54
55 @Test public final void testMatches_invalid2() {
56 assertFalse(pattern.matches("1234"));
57 }
58
59 @Test public final void testMatches_invalid3() {
60 assertFalse(pattern.matches("12345-12345"));
61 }
62
63 @Test public final void testMatches_invalid4() {
64 assertFalse(pattern.matches("12345-123"));
65 }
66 }