Add random positive time value convenience method
This commit adds a convenience method for producing random positive time values which can be useful for places where non-negative and non-zero time values are expected.
This commit is contained in:
parent
58b6db8d82
commit
69a3f7f590
|
@ -382,9 +382,18 @@ public abstract class ESTestCase extends LuceneTestCase {
|
|||
return generateRandomStringArray(maxArraySize, maxStringSize, allowNull, true);
|
||||
}
|
||||
|
||||
private static String[] TIME_SUFFIXES = new String[]{"d", "H", "ms", "s", "S", "w"};
|
||||
|
||||
private static String randomTimeValue(int lower, int upper) {
|
||||
return randomIntBetween(lower, upper) + randomFrom(TIME_SUFFIXES);
|
||||
}
|
||||
|
||||
public static String randomTimeValue() {
|
||||
final String[] values = new String[]{"d", "H", "ms", "s", "S", "w"};
|
||||
return randomIntBetween(0, 1000) + randomFrom(values);
|
||||
return randomTimeValue(0, 1000);
|
||||
}
|
||||
|
||||
public static String randomPositiveTimeValue() {
|
||||
return randomTimeValue(1, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue