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.fieldlevel;
17  
18  import org.junit.Test;
19  import org.kuali.rice.kns.datadictionary.validation.fieldlevel.MonthValidationPattern;
20  import org.kuali.test.KRADTestCase;
21  
22  import static org.junit.Assert.assertFalse;
23  import static org.junit.Assert.assertTrue;
24  
25  public class MonthValidationPatternTest extends KRADTestCase {
26      MonthValidationPattern pattern;
27  
28      @Override
29      public void setUp() throws Exception {
30          super.setUp();
31  
32          pattern = new MonthValidationPattern();
33      }
34  
35      @Test public final void testMatches_valid1() {
36          assertTrue(pattern.matches("1"));
37      }
38  
39      @Test public final void testMatches_valid2() {
40          assertTrue(pattern.matches("01"));
41      }
42  
43      @Test public final void testMatches_valid3() {
44          assertTrue(pattern.matches("11"));
45      }
46  
47  
48      @Test public final void testMatches_invalid1() {
49          assertFalse(pattern.matches("00"));
50      }
51  
52      @Test public final void testMatches_invalid2() {
53          assertFalse(pattern.matches("0"));
54      }
55  
56      @Test public final void testMatches_invalid3() {
57          assertFalse(pattern.matches("13"));
58      }
59  }