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