77import com .cronutils .model .definition .CronDefinitionBuilder ;
88import com .cronutils .model .time .ExecutionTime ;
99import com .cronutils .parser .CronParser ;
10+ import org .junit .Test ;
1011import org .junit .jupiter .api .Assertions ;
11- import org .junit .jupiter .api .Test ;
1212
1313import java .time .ZonedDateTime ;
1414import java .util .Locale ;
1515import java .util .Optional ;
1616
17- class Issue528Test {
18-
19- static final CronDefinition REBOOT_CRON_DEFINITION = CronDefinitionBuilder .defineCron ()
17+ public class Issue528Test {
18+ private static final CronDefinition REBOOT_CRON_DEFINITION = CronDefinitionBuilder .defineCron ()
2019 .withSupportedNicknameReboot ()
2120 .instance ();
2221
2322 @ Test
24- void testRebootExecutionTime () {
23+ public void testRebootExecutionTime () {
2524 Cron cron = new CronParser (REBOOT_CRON_DEFINITION ).parse ("@reboot" );
2625 ExecutionTime executionTime = ExecutionTime .forCron (cron );
2726 Assertions .assertEquals (Optional .empty (), executionTime .nextExecution (ZonedDateTime .now ()));
2827 Assertions .assertEquals (Optional .empty (), executionTime .lastExecution (ZonedDateTime .now ()));
2928 }
3029
3130 @ Test
32- void testCronDescriptor () {
31+ public void testCronDescriptor () {
3332 Cron cron = new CronParser (REBOOT_CRON_DEFINITION ).parse ("@reboot" );
3433 String description = CronDescriptor .instance (Locale .UK ).describe (cron );
3534 Assertions .assertEquals ("on reboot" , description );
3635 }
3736
38-
3937 @ Test
40- void testCronMapper () {
38+ public void testCronMapperRebootSupportedOnTarget () {
4139 Cron cron = new CronParser (REBOOT_CRON_DEFINITION ).parse ("@reboot" );
4240 CronDefinition unix = CronDefinitionBuilder .defineCron ()
4341 .withMinutes ().withValidRange (0 , 59 ).withStrictRange ().and ()
@@ -50,4 +48,18 @@ void testCronMapper() {
5048 Cron mapped = CronMapper .sameCron (unix ).map (cron );
5149 Assertions .assertEquals (cron .asString (), mapped .asString ());
5250 }
51+
52+ @ Test (expected = IllegalArgumentException .class )
53+ public void testCronMapperRebootNotSupportedOnTarget () {
54+ Cron cron = new CronParser (REBOOT_CRON_DEFINITION ).parse ("@reboot" );
55+ CronDefinition unix = CronDefinitionBuilder .defineCron ()
56+ .withMinutes ().withValidRange (0 , 59 ).withStrictRange ().and ()
57+ .withHours ().withValidRange (0 , 23 ).withStrictRange ().and ()
58+ .withDayOfMonth ().withValidRange (1 , 31 ).withStrictRange ().and ()
59+ .withMonth ().withValidRange (1 , 12 ).withStrictRange ().and ()
60+ .withDayOfWeek ().withValidRange (0 , 7 ).withMondayDoWValue (1 ).withIntMapping (7 , 0 ).withStrictRange ().and ()
61+ .instance ();
62+ Cron mapped = CronMapper .sameCron (unix ).map (cron );
63+ Assertions .assertEquals (cron .asString (), mapped .asString ());
64+ }
5365}
0 commit comments