Skip to content

Commit 5c2ad43

Browse files
authored
Merge pull request #414 from melonhead901/issue413
Fix interval notation in period error message. #413
2 parents 25c031c + 9c92f2d commit 5c2ad43

2 files changed

Lines changed: 25 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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.cronutils;
2+
3+
import com.cronutils.model.CronType;
4+
import com.cronutils.model.definition.CronDefinitionBuilder;
5+
import com.cronutils.parser.CronParser;
6+
import org.junit.Test;
7+
8+
import static org.junit.Assert.assertEquals;
9+
import static org.junit.Assert.fail;
10+
11+
public class Issue413Test {
12+
13+
@Test
14+
public void testFridayToSaturdayQuartz() {
15+
final CronParser parser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.UNIX));
16+
try {
17+
parser.parse("* * * */12 *");
18+
// expected to fail.
19+
fail();
20+
} catch (IllegalArgumentException expected) {
21+
assertEquals("Failed to parse '* * * */12 *'. Period 12 not in range [1, 12)", expected.getMessage());
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)