Skip to content

Commit a96f216

Browse files
committed
Fix interval notation in period error message. #413
1 parent 25c031c commit a96f216

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/main/java/com/cronutils/model/field/expression/visitor/ValidationFieldExpressionVisitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected void isPeriodInRange(final FieldValue<?> fieldValue) {
167167
final int value = ((IntegerFieldValue) fieldValue).getValue();
168168
if (!constraints.isPeriodInRange(value)) {
169169
throw new IllegalArgumentException(
170-
String.format("Period %s not in range (%s, %s]", value, constraints.getStartRange(), constraints.getEndRange()));
170+
String.format("Period %s not in range [%s, %s)", value, constraints.getStartRange(), constraints.getEndRange()));
171171
}
172172
}
173173
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.cronutils;
2+
3+
import com.cronutils.model.Cron;
4+
import com.cronutils.model.CronType;
5+
import com.cronutils.model.definition.CronDefinitionBuilder;
6+
import com.cronutils.parser.CronParser;
7+
import org.junit.Test;
8+
9+
import static org.junit.Assert.assertEquals;
10+
import static org.junit.Assert.fail;
11+
12+
public class Issue413Test {
13+
14+
@Test
15+
public void testFridayToSaturdayQuartz() {
16+
final CronParser parser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX));
17+
final Cron quartzCron = parser.parse("* * * */12 *");
18+
try {
19+
quartzCron.validate();
20+
// expected to fail.
21+
fail();
22+
} catch (IllegalArgumentException expected) {
23+
assertEquals("Failed to parse '* * * */12 *'. Period 12 not in range (1, 12]", expected.getMessage());
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)