package com.cronutils;

import com.cronutils.model.Cron;
import com.cronutils.model.definition.CronDefinition;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.model.time.ExecutionTime;
import com.cronutils.parser.CronParser;
import org.junit.*;
import org.threeten.bp.ZoneId;
import org.threeten.bp.ZonedDateTime;

import static com.cronutils.model.CronType.QUARTZ;
import static org.junit.Assert.*;

/**
 * Created by johnpatrick.manalo on 6/19/17.
 */
public class Issue200Test {
    // Does not pass!
    @Test
    public void testMustMatchCronEvenIfNanoSecondsVaries() {
        CronDefinition cronDefinition =
                CronDefinitionBuilder.instanceDefinitionFor(QUARTZ);

        CronParser parser = new CronParser(cronDefinition);
        Cron quartzCron = parser.parse("00 00 10 * * ?");

        quartzCron.validate();

        // NOTE: Off by 3 nano seconds
        ZonedDateTime zdt = ZonedDateTime.of(1999, 07, 18, 10, 00, 00, 03, ZoneId.systemDefault());

        // Must be true
        assertTrue("Nano seconds must not affect matching of Cron Expressions", ExecutionTime.forCron(quartzCron).isMatch(zdt));
    }

    // Nano second-perfect (passes, no surprises here)
    @Test
    public void testMatchExact() {
        CronDefinition cronDefinition =
                CronDefinitionBuilder.instanceDefinitionFor(QUARTZ);

        CronParser parser = new CronParser(cronDefinition);
        Cron quartzCron = parser.parse("00 00 10 * * ?");

        quartzCron.validate();

        ZonedDateTime zdt = ZonedDateTime.of(1999, 07, 18, 10, 00, 00, 00, ZoneId.systemDefault());

        assertTrue("Nano seconds must not affect matching of Cron Expressions", ExecutionTime.forCron(quartzCron).isMatch(zdt));
    }
}

@@ -531,24 +531,26 @@
 t pass!%0A    
+//
 @Test%0A    pu

Comment test for #Issue 200