001/**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krad.datadictionary.validation.fieldlevel;
017
018import org.junit.Test;
019import org.kuali.rice.kns.datadictionary.validation.fieldlevel.YearValidationPattern;
020import org.kuali.rice.krad.test.KRADTestCase;
021
022import static org.junit.Assert.assertFalse;
023import static org.junit.Assert.assertTrue;
024
025/**
026 * YearValidationPatternTest tests {@link YearValidationPattern}
027 *
028 * <p>Valid year values should match</p>
029 *
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 */
032public class YearValidationPatternTest extends KRADTestCase {
033    YearValidationPattern pattern;
034
035    @Override
036    public void setUp() throws Exception {
037        super.setUp();
038
039        pattern = new YearValidationPattern();
040    }
041
042    @Test public final void testMatches_valid1() {
043        assertTrue(pattern.matches("1901"));
044    }
045
046    @Test public final void testMatches_valid2() {
047        assertTrue(pattern.matches("1991"));
048    }
049
050    @Test public final void testMatches_valid3() {
051        assertTrue(pattern.matches("2005"));
052    }
053
054    @Test public final void testMatches_valid4() {
055        assertTrue(pattern.matches("1837"));
056    }
057
058
059    @Test public final void testMatches_invalid1() {
060        assertFalse(pattern.matches("992"));
061    }
062
063    @Test public final void testMatches_invalid2() {
064        assertFalse(pattern.matches("1514"));
065    }
066
067    @Test public final void testMatches_invalid3() {
068        assertFalse(pattern.matches("3103"));
069    }
070
071    @Test public final void testMatches_invalid4() {
072        assertFalse(pattern.matches("10001"));
073    }
074}