1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation;
17
18 import static org.junit.Assert.fail;
19
20
21
22
23
24
25 public final class ValidationTestUtils {
26 private static final String[] TEST_INPUTS = { "", "!!!", "[a-9]", "^A-Z", "abc", "a bc", "a_bc", "123", "12 3", "12_3", "a1b2c3", "a1b2_c3", "a 1b2c3", "a 1b2_c3", "foo.bar", "foo.bar_baz", ".bar_foo baz" };
27
28 private ValidationTestUtils() {
29 throw new UnsupportedOperationException("do not call");
30 }
31
32
33
34
35
36
37 public static final void assertPatternMatches(ValidationPattern pattern, boolean[] expectedValues) {
38 if (expectedValues.length != TEST_INPUTS.length) {
39 fail("expectedValues length was " + expectedValues.length + ", expected TEST_INPUTS.length of " + TEST_INPUTS.length);
40 }
41
42 for (int i = 0; i < TEST_INPUTS.length; ++i) {
43 String testInput = TEST_INPUTS[i];
44 boolean expectedResult = expectedValues[i];
45
46 boolean actualResult = pattern.matches(testInput);
47 if (actualResult != expectedResult) {
48 fail("for input '" + testInput + "', expected " + expectedResult + " but got " + actualResult);
49 }
50 }
51 }
52 }