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.JavaClassValidationPattern;
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 JavaClassValidationPatternTest extends KRADTestCase {
27 JavaClassValidationPattern pattern;
28
29 @Override
30 public void setUp() throws Exception {
31 super.setUp();
32
33 pattern = new JavaClassValidationPattern();
34 }
35
36 @Test public final void testMatches_actualClass() {
37 assertTrue(pattern.matches(String.class.getName()));
38 }
39
40 @Test public final void testMatches_fictitiousClass() {
41 assertTrue(pattern.matches("something.wicked.this.way.Comes"));
42 }
43
44 @Test public final void testMatches_unqualifiedClass() {
45 assertTrue(pattern.matches("String"));
46 }
47
48 @Test public final void testMatches_invalidClassname1() {
49 assertFalse(pattern.matches("23Tests"));
50 }
51
52 @Test public final void testMatches_invalidClassname2() {
53 assertFalse(pattern.matches("more tests"));
54 }
55
56 @Test public final void testMatches_invalidClassname3() {
57 assertFalse(pattern.matches("more.and.more:tests"));
58 }
59
60 @Test public final void testMatches_invalidClassname4() {
61 assertFalse(pattern.matches("still.more.tests."));
62 }
63 }