1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.datadictionary.validation.charlevel;
17
18 import org.junit.Test;
19 import org.kuali.rice.kns.datadictionary.validation.charlevel.NumericValidationPattern;
20 import org.kuali.rice.krad.datadictionary.validation.ValidationTestUtils;
21 import org.kuali.rice.test.BaseRiceTestCase;
22
23 /**
24 * tests {@link NumericValidationPattern}
25 *
26 * @author Kuali Rice Team (rice.collab@kuali.org)
27 */
28 public class NumericValidationPatternTest extends BaseRiceTestCase {
29 private NumericValidationPattern pattern;
30
31
32 public void setUp() throws Exception {
33 pattern = new NumericValidationPattern();
34 }
35
36 /**
37 * tests that sequences containing only numbers match
38 */
39 @Test public final void testMatch_allowDefault() {
40 boolean[] expected = { true, // ""
41 false, // "!!!"
42 false, // "[a-9]"
43 false, // "^A-Z"
44 false, // "abc"
45 false, // "a bc"
46 false, // "a_bc"
47 true, // "123"
48 false, // "12 3"
49 false, // "12_3"
50 false, // "a1b2c3"
51 false, // "a1b2_c3"
52 false, // "a 1b2c3"
53 false, // "a 1b2_c3"
54 false, //"foo.bar"
55 false, //"foo.bar_baz"
56 false, //".bar_foo baz"
57 };
58
59 ValidationTestUtils.assertPatternMatches(pattern, expected);
60 }
61 }