You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@francisdb provided the following tests when discussing issue #89
Tests should be merged into out codebase, to cover a broader set of cases.
"Validating a cron expression" should {
"succeed for a valid cron expression 0 0/15 * * * ?" in {
CronUtil.validateCronExpression("0 0/15 * * * ?", true)
success
}
"throw an exception when given an invalid cron expression for quartz" in {
CronUtil.validateCronExpression("0 30 17 4 1 * 2016", false) must throwA[IllegalArgumentException](
Pattern.quote("Both, a day-of-week AND a day-of-month parameter, are not supported.")
)
}
"throw an exception for invalid cron expression with unknown char" in {
CronUtil.validateCronExpression("* * * * $ ?", false) must throwA[IllegalArgumentException](
// TODO should be better with https://github.com/jmrozanec/cron-utils/issues/89
Pattern.quote("""java.lang.NumberFormatException: For input string: "$"""")
)
}
"for an invalid quartz cron expression throw an exception with message containing the actual expression" in {
skipped("https://github.com/jmrozanec/cron-utils/issues/90")
CronUtil.validateCronExpression("0/1 * * * * *", false) must throwA[IllegalArgumentException](
Pattern.quote("""Invalid cron expression: 0/1 * * * * *. Both, a day-of-week AND a day-of-month parameter, are not supported.""")
)
}
}
"Calculating the minimum interval for a cron expression" should {
"be 1 for * * * * * ?" in {
CronUtil.getShortestPeriodSeconds("* * * * * ?", Duration.ZERO) must be equalTo Duration.ofSeconds(1)
}
"be 1 for * * * * * ? (ignore whitespace)" in {
CronUtil.getShortestPeriodSeconds("* * * * * ?", Duration.ZERO) must be equalTo Duration.ofSeconds(1)
}
"be 1 for 0/1 * * * * ?" in {
CronUtil.getShortestPeriodSeconds("0/1 * * * * ?", Duration.ZERO) must be equalTo Duration.ofSeconds(1)
}
"be 1 for */1 * * * * ?" in {
CronUtil.getShortestPeriodSeconds("*/1 * * * * ?", Duration.ZERO) must be equalTo Duration.ofSeconds(1)
}
"be 60 for 0 * * * * ?" in {
CronUtil.getShortestPeriodSeconds("0 * * * * ?", Duration.ZERO) must be equalTo Duration.ofMinutes(1)
}
"be 60 for 0 */1 * * * ?" in {
CronUtil.getShortestPeriodSeconds("0 */1 * * * ?", Duration.ZERO) must be equalTo Duration.ofMinutes(1)
}
"be 300 for 0 */5 * * * ?" in {
CronUtil.getShortestPeriodSeconds("0 */5 * * * ?", Duration.ZERO) must be equalTo Duration.ofMinutes(5)
}
"be 3600 for 0 0 * * * ?" in {
CronUtil.getShortestPeriodSeconds("0 0 * * * ?", Duration.ZERO) must be equalTo Duration.ofHours(1)
}
"be 10800 for 0 0 */3 * * ?" in {
CronUtil.getShortestPeriodSeconds("0 0 */3 * * ?", Duration.ZERO) must be equalTo Duration.ofHours(3)
}
"be 86400 for 0 0 0 * * ?" in {
CronUtil.getShortestPeriodSeconds("0 0 0 * * ?", Duration.ofDays(1)) must be equalTo Duration.ofDays(1)
}
"throw an exception for invalid cron expression * *" in {
CronUtil.getShortestPeriodSeconds("* *", Duration.ZERO) must throwA[IllegalArgumentException](
Pattern.quote("Cron expression contains 2 parts but we expect one of [6, 7]")
)
}
"throw an exception for invalid cron expression */ * * * * ?" in {
CronUtil.getShortestPeriodSeconds("*/ * * * * ?", Duration.ZERO) must throwA[IllegalArgumentException](
Pattern.quote("Missing steps for expression: */")
)
}
"throw an exception for invalid cron expression with unknown char" in {
CronUtil.getShortestPeriodSeconds("* * * * $ ?", Duration.ZERO) must throwA[IllegalArgumentException](
// TODO should be better with https://github.com/jmrozanec/cron-utils/issues/89
Pattern.quote("""java.lang.NumberFormatException: For input string: "$"""")
)
}
The text was updated successfully, but these errors were encountered:
@francisdb provided the following tests when discussing issue #89
Tests should be merged into out codebase, to cover a broader set of cases.
The text was updated successfully, but these errors were encountered: