package com.cronutils;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.cronutils.mapper.CronMapper;
import com.cronutils.model.Cron;
import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;

import org.junit.jupiter.api.Disabled;
import org.junit.Test;

class Issue499Test {
    /**
     * We want to convert Unix cron expressions to Quartz cron expressions. We 
     * expect an exception: java.lang.IllegalArgumentException:
     * Failed to parse '12 1 * ? *'. Invalid expression: ?
     * Given question marks are not supported at Unix crons. See: 
     * https://github.com/jmrozanec/cron-utils/issues/499
     */
    @Test(expected = IllegalArgumentException.class)
    void testCronExpressionForConversionToQuartz() {
        final CronParser unixParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX));
        final CronMapper unixToQuartz = CronMapper.fromUnixToQuartz();
        final String unixExpression = "12 1 * ? *";
        // Works on 5.0.5, throws IllegalArgumentException in 9.1.3
        final Cron unixCron = unixParser.parse(unixExpression);
        // Goal: Convert unix expressions to quartz.
        final String quartzExpression = unixToQuartz.map(unixCron).asString();
        // This is what we expected.
        assertEquals("0 12 1 * ? ? *", quartzExpression);
    }
}

@@ -74,89 +74,16 @@
 sert
-Equals;%0A%0Aimport com.cronutils.mapper.CronMapper;%0Aimport com.cronutils.model.Cron;
+Throws;%0A
 %0Aimp
@@ -251,35 +251,8 @@
 api.
-Disabled;%0Aimport org.junit.
 Test
@@ -361,17 +361,16 @@
 ions. We
- 
 %0A     * 
@@ -550,17 +550,16 @@
 ns. See:
- 
 %0A     * 
@@ -630,51 +630,8 @@
 Test
-(expected = IllegalArgumentException.class)
 %0A   
@@ -798,79 +798,8 @@
 ));%0A
-        final CronMapper unixToQuartz = CronMapper.fromUnixToQuartz();%0A
     
@@ -926,278 +926,80 @@
     
-final Cron unixCron = unixParser.parse(unixExpression);%0A        // Goal: Convert unix expressions to quartz.%0A        final String quartzExpression = unixToQuartz.map(unixCron).asString();%0A        // This is what we expected.%0A        assertEquals(%220 12 1 * ? ? *%22, quartz
+assertThrows(IllegalArgumentException.class, () -%3E unixParser.parse(unix
 Expr
@@ -1005,16 +1005,17 @@
 ression)
+)
 ;%0A    %7D%0A

Fix Issue499Test