Skip to content

Commit ac37cfa

Browse files
committed
Update testcases
1 parent 32dfa96 commit ac37cfa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

server/src/main/java/org/elasticsearch/common/time/DateUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public static long roundMonthOfYear(final long utcMillis) {
374374
*/
375375
public static long roundIntervalMonthOfYear(final long utcMillis, final int monthInterval) {
376376
if (monthInterval <= 0) {
377-
throw new IllegalArgumentException("month interval must be strictly positive, got [" + monthInterval + "]");
377+
throw new IllegalArgumentException("month interval must be strictly positive, got [" + monthInterval + "]");
378378
}
379379
int year = getYear(utcMillis);
380380
int month = getMonthOfYear(utcMillis, year);
@@ -400,7 +400,7 @@ public static long roundYear(final long utcMillis) {
400400
*/
401401
public static long roundYearInterval(final long utcMillis, final int yearInterval) {
402402
if (yearInterval <= 0) {
403-
throw new IllegalArgumentException("year interval [" + yearInterval + "] must be positive");
403+
throw new IllegalArgumentException("year interval must be strictly positive, got [" + yearInterval + "]");
404404
}
405405
int year = getYear(utcMillis);
406406
return utcMillisAtStartOfYear(((year - 1) / yearInterval) * yearInterval + 1);
@@ -425,7 +425,7 @@ public static long roundWeekOfWeekYear(final long utcMillis) {
425425
*/
426426
public static long roundWeekIntervalOfWeekYear(final long utcMillis, final int weekInterval) {
427427
if (weekInterval <= 0) {
428-
throw new IllegalArgumentException("week interval [" + weekInterval + "] must be positive");
428+
throw new IllegalArgumentException("week interval must be strictly positive, got [" + weekInterval + "]");
429429
}
430430
return roundFloor(utcMillis + 3 * 86400 * 1000L, 604800000L * weekInterval) - 3 * 86400 * 1000L;
431431
}

server/src/test/java/org/elasticsearch/common/time/DateUtilsTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ public void testRoundMonthOfYear() {
230230
assertThat(DateUtils.roundMonthOfYear(-1), is(dec1969));
231231

232232
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> DateUtils.roundIntervalMonthOfYear(0, -1));
233-
assertThat(exc.getMessage(), is("month interval [-1] must be positive"));
233+
assertThat(exc.getMessage(), is("month interval must be strictly positive, got [-1]"));
234234
assertThat(DateUtils.roundIntervalMonthOfYear(1, 5), is(0L));
235235
long epochMilli = LocalDate.of(1969, 7, 1).atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
236236
assertThat(DateUtils.roundIntervalMonthOfYear(-1, 13), is(epochMilli));
@@ -251,7 +251,7 @@ public void testRoundYear() {
251251
assertThat(DateUtils.roundYear(endOf1996), is(startOf1996));
252252

253253
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> DateUtils.roundYearInterval(0, -1));
254-
assertThat(exc.getMessage(), is("year interval [-1] must be positive"));
254+
assertThat(exc.getMessage(), is("year interval must be strictly positive, got [-1]"));
255255
assertThat(DateUtils.roundYearInterval(0, 2), is(startOf1969));
256256
long startOf1968 = Year.of(1968).atDay(1).atStartOfDay().toInstant(ZoneOffset.UTC).toEpochMilli();
257257
assertThat(DateUtils.roundYearInterval(0, 7), is(startOf1968));
@@ -270,7 +270,7 @@ public void testRoundWeek() {
270270
assertThat(DateUtils.roundWeekOfWeekYear(-1), is(epochMilli));
271271

272272
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> DateUtils.roundWeekIntervalOfWeekYear(0, -1));
273-
assertThat(exc.getMessage(), is("week interval [-1] must be positive"));
273+
assertThat(exc.getMessage(), is("week interval must be strictly positive, got [-1]"));
274274
assertThat(DateUtils.roundWeekIntervalOfWeekYear(0, 3), is(epochMilli));
275275
assertThat(DateUtils.roundWeekIntervalOfWeekYear(1, 3), is(epochMilli));
276276
assertThat(DateUtils.roundWeekIntervalOfWeekYear(-1, 2), is(epochMilli));

0 commit comments

Comments
 (0)