Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public ScheduleRange(int start) {
* Create a inclusive range for a schedule match value.
*
* @param start The inclusive start of the range
* @param end The inclusive end of the range. Default if unset or less than start is start.
* @param end The inclusive end of the range. Must be non-negative. Default if unset or less than
* start is start.
* @throws IllegalStateException if start or end is negative
*/
public ScheduleRange(int start, int end) {
this(start, end, 0);
Expand All @@ -32,11 +34,13 @@ public ScheduleRange(int start, int end) {
* Create a inclusive range for a schedule match value.
*
* @param start The inclusive start of the range
* @param end The inclusive end of the range. Default if unset or less than start is start.
* @param end The inclusive end of the range. Must be non-negative. Default if unset or less than
* start is start.
* @param step The step to take between each value. Default if unset or 0, is 1.
* @throws IllegalStateException if start, end, or step is negative
*/
public ScheduleRange(int start, int end, int step) {
Preconditions.checkState(start >= 0 && step >= 0 && step >= 0);
Preconditions.checkState(start >= 0 && end >= 0 && step >= 0);
this.start = start;
this.end = end;
this.step = step;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.temporal.client.schedules;

import org.junit.Assert;
import org.junit.Test;

public class ScheduleRangeTest {
@Test
public void rejectsNegativeEnd() {
Assert.assertThrows(IllegalStateException.class, () -> new ScheduleRange(0, -1));
Assert.assertThrows(IllegalStateException.class, () -> new ScheduleRange(0, -1, 0));
}
}