View Javadoc
1   /**
2    * Copyright 2005-2011 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  public class NumericValidationPatternTest extends BaseRiceTestCase {
24      private NumericValidationPattern pattern;
25  
26      
27      public void setUp() throws Exception {
28          pattern = new NumericValidationPattern();
29      }
30  
31  
32      @Test public final void testMatch_allowDefault() {
33          boolean[] expected = { true, // ""
34                  false, // "!!!"
35                  false, // "[a-9]"
36                  false, // "^A-Z"
37                  false, // "abc"
38                  false, // "a bc"
39                  false, // "a_bc"
40                  true, // "123"
41                  false, // "12 3"
42                  false, // "12_3"
43                  false, // "a1b2c3"
44                  false, // "a1b2_c3"
45                  false, // "a 1b2c3"
46                  false, // "a 1b2_c3"
47                  false, //"foo.bar"
48                  false, //"foo.bar_baz"
49                  false, //".bar_foo baz"
50          };
51  
52          ValidationTestUtils.assertPatternMatches(pattern, expected);
53      }
54  }