forked from jmrozanec/cron-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add day of month to day of week,
X#Y
syntax
Resolves jmrozanec#605
- Loading branch information
Showing
3 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.cronutils; | ||
|
||
import com.cronutils.mapper.CronMapper; | ||
import com.cronutils.model.Cron; | ||
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.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.stream.Stream; | ||
|
||
import static com.cronutils.model.CronType.QUARTZ; | ||
import static com.cronutils.model.CronType.SPRING; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
|
||
class Issue605Test { | ||
|
||
static Stream<Arguments> cronExpressions() { | ||
return Stream.of( | ||
Arguments.of(QUARTZ, CronMapper.fromQuartzToCron4j()), | ||
Arguments.of(QUARTZ, CronMapper.fromQuartzToSpring()), | ||
Arguments.of(QUARTZ, CronMapper.fromQuartzToUnix()), | ||
Arguments.of(SPRING, CronMapper.fromSpringToQuartz()) | ||
); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("cronExpressions") | ||
void testDayOfWeekMappingSpring(CronType cronType, CronMapper mapper) { | ||
Cron cron = getCron(cronType, "0 0 0 ? * 5#1"); | ||
assertDoesNotThrow(() -> mapper.map(cron)); | ||
} | ||
|
||
private Cron getCron(CronType cronType, @SuppressWarnings("SameParameterValue") final String quartzExpression) { | ||
final CronDefinition cronDefinition = CronDefinitionBuilder.instanceDefinitionFor(cronType); | ||
final CronParser parser = new CronParser(cronDefinition); | ||
return parser.parse(quartzExpression); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters