View Javadoc
1   /**
2    * Copyright 2005-2014 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.rice.krad.test.KRADTestCase;
21  
22  import static org.junit.Assert.assertFalse;
23  import static org.junit.Assert.assertTrue;
24  
25  /**
26   * MonthValidationPatternTest tests {@link MonthValidationPattern}
27   *
28   * <p>Valid months (01-12) should match</p>
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class MonthValidationPatternTest extends KRADTestCase {
33      MonthValidationPattern pattern;
34  
35      @Override
36      public void setUp() throws Exception {
37          super.setUp();
38  
39          pattern = new MonthValidationPattern();
40      }
41  
42      @Test public final void testMatches_valid1() {
43          assertTrue(pattern.matches("1"));
44      }
45  
46      @Test public final void testMatches_valid2() {
47          assertTrue(pattern.matches("01"));
48      }
49  
50      @Test public final void testMatches_valid3() {
51          assertTrue(pattern.matches("11"));
52      }
53  
54  
55      @Test public final void testMatches_invalid1() {
56          assertFalse(pattern.matches("00"));
57      }
58  
59      @Test public final void testMatches_invalid2() {
60          assertFalse(pattern.matches("0"));
61      }
62  
63      @Test public final void testMatches_invalid3() {
64          assertFalse(pattern.matches("13"));
65      }
66  }