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