<commit_before>package com.cronutils.validator;

import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinition;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;
import org.junit.Before;
import org.junit.Test;

/*
 * Copyright 2015 jmrozanec
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
public class CronValidatorQuartzIntegrationTest {
    private CronDefinition quartz;

    @Before
    public void setUp() throws Exception {
        quartz = CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ);
    }

    /**
     * Issue #27: range is valid
     */
    @Test
    public void testMonthRangeMappingIsValid(){
        CronValidator validator = new CronValidator(quartz);
        validator.isValid("0 0 0 * JUL-AUG * *");
    }
}<commit_msg>Issue #27: Add Quartz CronValidator test cases to handle string mapping of months and day of week mappings.<commit_after>package com.cronutils.validator;

import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinitionBuilder;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;

import java.util.Locale;

import static org.junit.Assert.assertTrue;

/*
 * Copyright 2015 jmrozanec
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
public class CronValidatorQuartzIntegrationTest {
    private CronValidator validator;

    @Before
    public void setUp() throws Exception {
        validator = new CronValidator(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
    }

    /**
     * Issue #27: month range string mapping is valid
     */
    @Test
    public void testMonthRangeMappingIsValid(){
        assertTrue(validator.isValid("0 0 0 * JUL-AUG * *"));
    }

    /**
     * Issue #27: single month string mapping is valid
     */
    //TODO
    public void testSingleMonthMappingIsValid(){
        DateTime date = new DateTime(2015, 1, 1, 1, 1);
        for(int j=0;j<12;j++){
            String expression = String.format("0 0 0 * %s * *", date.plusMonths(j).toString("MMM", Locale.US).toUpperCase());
            assertTrue(String.format("We expect '%s' to be valid", expression), validator.isValid(expression));
        }
    }

    /**
     * Issue #27: day of week range string mapping is valid
     */
    @Test
    public void testDayOfWeekRangeMappingIsValid(){
        assertTrue(validator.isValid("0 0 0 * * MON-FRI *"));
    }

    /**
     * Issue #27: single day of week string mapping is valid
     */
    //TODO
    public void testDayOfWeekMappingIsValid(){
        for(String dow : new String[]{"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}){
            String expression = String.format("0 0 0 * * %s *", dow);
            assertTrue(String.format("We expect '%s' to be valid", expression), validator.isValid(expression));
        }

    }
}
{'fraction_non_alphanumeric': 0.10131817006978547, 'fraction_numerical': 0.01395709485655208, 'mean_word_length': 3.397727272727273, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6819156', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1079, 'n_words': 367}