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.YearValidationPattern;
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 public class YearValidationPatternTest extends KRADTestCase {
28 YearValidationPattern pattern;
29
30 @Override
31 public void setUp() throws Exception {
32 super.setUp();
33
34 pattern = new YearValidationPattern();
35 }
36
37 @Test public final void testMatches_valid1() {
38 assertTrue(pattern.matches("1901"));
39 }
40
41 @Test public final void testMatches_valid2() {
42 assertTrue(pattern.matches("1991"));
43 }
44
45 @Test public final void testMatches_valid3() {
46 assertTrue(pattern.matches("2005"));
47 }
48
49 @Test public final void testMatches_valid4() {
50 assertTrue(pattern.matches("1837"));
51 }
52
53
54 @Test public final void testMatches_invalid1() {
55 assertFalse(pattern.matches("992"));
56 }
57
58 @Test public final void testMatches_invalid2() {
59 assertFalse(pattern.matches("1514"));
60 }
61
62 @Test public final void testMatches_invalid3() {
63 assertFalse(pattern.matches("3103"));
64 }
65
66 @Test public final void testMatches_invalid4() {
67 assertFalse(pattern.matches("10001"));
68 }
69 }