Clean up assertions in `DurationsTest` and `TimestampsTest` a bit.

PiperOrigin-RevId: 572279223
pull/14336/head
Kurt Alfred Kluever 1 year ago committed by Copybara-Service
parent 19aad63844
commit 833ded7298
  1. 41
      java/util/src/test/java/com/google/protobuf/util/DurationsTest.java
  2. 111
      java/util/src/test/java/com/google/protobuf/util/TimestampsTest.java

@ -165,7 +165,7 @@ public class DurationsTest {
@Test @Test
public void testParse_outOfRange() throws ParseException { public void testParse_outOfRange() throws ParseException {
try { try {
Duration x = Durations.parse("316576000000.123456789123456789s"); Durations.parse("316576000000.123456789123456789s");
fail("expected ParseException"); fail("expected ParseException");
} catch (ParseException expected) { } catch (ParseException expected) {
assertThat(expected).hasMessageThat().isEqualTo("Duration value is out of range."); assertThat(expected).hasMessageThat().isEqualTo("Duration value is out of range.");
@ -507,60 +507,65 @@ public class DurationsTest {
public void testOverflows() throws Exception { public void testOverflows() throws Exception {
try { try {
Durations.toNanos(duration(315576000000L, 999999999)); Durations.toNanos(duration(315576000000L, 999999999));
assertWithMessage("Expected an ArithmeticException to be thrown").fail(); fail("Expected an ArithmeticException to be thrown");
} catch (ArithmeticException expected) { } catch (ArithmeticException expected) {
} }
try { try {
Durations.add(Durations.MAX_VALUE, Durations.MAX_VALUE); Durations.add(Durations.MAX_VALUE, Durations.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) {
}
try {
Durations.subtract(Durations.MAX_VALUE, Durations.MIN_VALUE);
fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.subtract(Durations.MIN_VALUE, Durations.MAX_VALUE); Durations.subtract(Durations.MIN_VALUE, Durations.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toNanos(INVALID_MAX); Durations.toNanos(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toMicros(INVALID_MAX); Durations.toMicros(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toMillis(INVALID_MAX); Durations.toMillis(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toSeconds(INVALID_MAX); Durations.toSeconds(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toNanos(INVALID_MIN); Durations.toNanos(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toMicros(INVALID_MIN); Durations.toMicros(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toMillis(INVALID_MIN); Durations.toMillis(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.toSeconds(INVALID_MIN); Durations.toSeconds(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
@ -568,17 +573,17 @@ public class DurationsTest {
.isEqualTo("9223372036.854775807s"); .isEqualTo("9223372036.854775807s");
try { try {
Durations.fromMicros(Long.MAX_VALUE); Durations.fromMicros(Long.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.fromMillis(Long.MAX_VALUE); Durations.fromMillis(Long.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.fromSeconds(Long.MAX_VALUE); Durations.fromSeconds(Long.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
@ -586,17 +591,17 @@ public class DurationsTest {
.isEqualTo("-9223372036.854775808s"); .isEqualTo("-9223372036.854775808s");
try { try {
Durations.fromMicros(Long.MIN_VALUE); Durations.fromMicros(Long.MIN_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.fromMillis(Long.MIN_VALUE); Durations.fromMillis(Long.MIN_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
try { try {
Durations.fromSeconds(Long.MIN_VALUE); Durations.fromSeconds(Long.MIN_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }

@ -8,8 +8,8 @@
package com.google.protobuf.util; package com.google.protobuf.util;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.protobuf.util.DurationsTest.duration; import static com.google.protobuf.util.DurationsTest.duration;
import static org.junit.Assert.fail;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.protobuf.Duration; import com.google.protobuf.Duration;
@ -21,7 +21,6 @@ import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.JUnit4; import org.junit.runners.JUnit4;
@ -77,7 +76,7 @@ public class TimestampsTest {
return; return;
} }
} }
assertWithMessage("no timestamp had sub-millisecond precision").fail(); fail("no timestamp had sub-millisecond precision");
} }
@Test @Test
@ -232,7 +231,7 @@ public class TimestampsTest {
Timestamp value = Timestamp value =
Timestamp.newBuilder().setSeconds(Timestamps.TIMESTAMP_SECONDS_MIN - 1).build(); Timestamp.newBuilder().setSeconds(Timestamps.TIMESTAMP_SECONDS_MIN - 1).build();
Timestamps.toString(value); Timestamps.toString(value);
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -244,7 +243,7 @@ public class TimestampsTest {
Timestamp value = Timestamp value =
Timestamp.newBuilder().setSeconds(Timestamps.TIMESTAMP_SECONDS_MAX + 1).build(); Timestamp.newBuilder().setSeconds(Timestamps.TIMESTAMP_SECONDS_MAX + 1).build();
Timestamps.toString(value); Timestamps.toString(value);
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -255,7 +254,7 @@ public class TimestampsTest {
// Invalid nanos value. // Invalid nanos value.
Timestamp value = Timestamp.newBuilder().setNanos(-1).build(); Timestamp value = Timestamp.newBuilder().setNanos(-1).build();
Timestamps.toString(value); Timestamps.toString(value);
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -266,7 +265,7 @@ public class TimestampsTest {
// Invalid nanos value. // Invalid nanos value.
Timestamp value = Timestamp.newBuilder().setNanos(1000000000).build(); Timestamp value = Timestamp.newBuilder().setNanos(1000000000).build();
Timestamps.toString(value); Timestamps.toString(value);
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -275,16 +274,16 @@ public class TimestampsTest {
public void testTimestampInvalidFormatDateTooSmall() { public void testTimestampInvalidFormatDateTooSmall() {
try { try {
Timestamps.parse("0000-01-01T00:00:00Z"); Timestamps.parse("0000-01-01T00:00:00Z");
Assert.fail(); fail();
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
assertThat(expected).hasCauseThat().isNotNull(); assertThat(expected).hasCauseThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("0000-01-01T00:00:00Z"); Timestamps.parseUnchecked("0000-01-01T00:00:00Z");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -292,15 +291,15 @@ public class TimestampsTest {
public void testTimestampInvalidFormatDateTooLarge() { public void testTimestampInvalidFormatDateTooLarge() {
try { try {
Timestamps.parse("10000-01-01T00:00:00Z"); Timestamps.parse("10000-01-01T00:00:00Z");
Assert.fail(); fail();
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("10000-01-01T00:00:00Z"); Timestamps.parseUnchecked("10000-01-01T00:00:00Z");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -308,15 +307,15 @@ public class TimestampsTest {
public void testTimestampInvalidFormatMissingT() { public void testTimestampInvalidFormatMissingT() {
try { try {
Timestamps.parse("1970-01-01 00:00:00Z"); Timestamps.parse("1970-01-01 00:00:00Z");
Assert.fail(); fail();
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("1970-01-01 00:00:00Z"); Timestamps.parseUnchecked("1970-01-01 00:00:00Z");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -324,15 +323,15 @@ public class TimestampsTest {
public void testTimestampInvalidFormatMissingZ() { public void testTimestampInvalidFormatMissingZ() {
try { try {
Timestamps.parse("1970-01-01T00:00:00"); Timestamps.parse("1970-01-01T00:00:00");
assertWithMessage("ParseException is expected.").fail(); fail("ParseException is expected.");
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("1970-01-01T00:00:00"); Timestamps.parseUnchecked("1970-01-01T00:00:00");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -340,15 +339,15 @@ public class TimestampsTest {
public void testTimestampInvalidOffset() { public void testTimestampInvalidOffset() {
try { try {
Timestamps.parse("1970-01-01T00:00:00+0000"); Timestamps.parse("1970-01-01T00:00:00+0000");
assertWithMessage("ParseException is expected.").fail(); fail("ParseException is expected.");
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("1970-01-01T00:00:00+0000"); Timestamps.parseUnchecked("1970-01-01T00:00:00+0000");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -356,13 +355,13 @@ public class TimestampsTest {
public void testTimestampInvalidOffsetWithDot() { public void testTimestampInvalidOffsetWithDot() {
try { try {
Timestamps.parse("2021-08-19T10:24:25-07.:00"); Timestamps.parse("2021-08-19T10:24:25-07.:00");
assertWithMessage("ParseException is expected.").fail(); fail("ParseException is expected.");
} catch (ParseException expected) { } catch (ParseException expected) {
assertThat(expected).hasMessageThat().isNotNull(); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("2021-08-19T10:24:25-07.:00"); Timestamps.parseUnchecked("2021-08-19T10:24:25-07.:00");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
assertThat(expected).hasMessageThat().isNotNull(); assertThat(expected).hasMessageThat().isNotNull();
} }
@ -372,15 +371,15 @@ public class TimestampsTest {
public void testTimestampInvalidTrailingText() { public void testTimestampInvalidTrailingText() {
try { try {
Timestamps.parse("1970-01-01T00:00:00Z0"); Timestamps.parse("1970-01-01T00:00:00Z0");
assertWithMessage("ParseException is expected.").fail(); fail("ParseException is expected.");
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("1970-01-01T00:00:00Z0"); Timestamps.parseUnchecked("1970-01-01T00:00:00Z0");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -388,15 +387,15 @@ public class TimestampsTest {
public void testTimestampInvalidNanoSecond() { public void testTimestampInvalidNanoSecond() {
try { try {
Timestamps.parse("1970-01-01T00:00:00.ABCZ"); Timestamps.parse("1970-01-01T00:00:00.ABCZ");
assertWithMessage("ParseException is expected.").fail(); fail("ParseException is expected.");
} catch (ParseException expected) { } catch (ParseException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
try { try {
Timestamps.parseUnchecked("1970-01-01T00:00:00.ABCZ"); Timestamps.parseUnchecked("1970-01-01T00:00:00.ABCZ");
assertWithMessage("IllegalArgumentException is expected.").fail(); fail("IllegalArgumentException is expected.");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
Assert.assertNotNull(expected.getMessage()); assertThat(expected).hasMessageThat().isNotNull();
} }
} }
@ -448,7 +447,7 @@ public class TimestampsTest {
Date date = calendar.getTime(); Date date = calendar.getTime();
try { try {
Timestamps.fromDate(date); Timestamps.fromDate(date);
Assert.fail("should have thrown IllegalArgumentException"); fail("should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
assertThat(expected).hasMessageThat().startsWith("Timestamp is not valid."); assertThat(expected).hasMessageThat().startsWith("Timestamp is not valid.");
} }
@ -464,7 +463,7 @@ public class TimestampsTest {
Date date = calendar.getTime(); Date date = calendar.getTime();
try { try {
Timestamps.fromDate(date); Timestamps.fromDate(date);
Assert.fail("should have thrown IllegalArgumentException"); fail("should have thrown IllegalArgumentException");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
assertThat(expected).hasMessageThat().startsWith("Timestamp is not valid."); assertThat(expected).hasMessageThat().startsWith("Timestamp is not valid.");
} }
@ -607,7 +606,7 @@ public class TimestampsTest {
public void testOverflowsArithmeticException() throws Exception { public void testOverflowsArithmeticException() throws Exception {
try { try {
Timestamps.toNanos(Timestamps.parse("9999-12-31T23:59:59.999999999Z")); Timestamps.toNanos(Timestamps.parse("9999-12-31T23:59:59.999999999Z"));
assertWithMessage("Expected an ArithmeticException to be thrown").fail(); fail("Expected an ArithmeticException to be thrown");
} catch (ArithmeticException expected) { } catch (ArithmeticException expected) {
} }
} }
@ -616,7 +615,7 @@ public class TimestampsTest {
public void testPositiveOverflow() { public void testPositiveOverflow() {
try { try {
Timestamps.add(Timestamps.MAX_VALUE, Durations.MAX_VALUE); Timestamps.add(Timestamps.MAX_VALUE, Durations.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -625,7 +624,7 @@ public class TimestampsTest {
public void testNegativeOverflow() { public void testNegativeOverflow() {
try { try {
Timestamps.subtract(Timestamps.MIN_VALUE, Durations.MAX_VALUE); Timestamps.subtract(Timestamps.MIN_VALUE, Durations.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -634,7 +633,7 @@ public class TimestampsTest {
public void testInvalidMaxNanosecondsOverflow() { public void testInvalidMaxNanosecondsOverflow() {
try { try {
Timestamps.toNanos(INVALID_MAX); Timestamps.toNanos(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -643,7 +642,7 @@ public class TimestampsTest {
public void testInvalidMaxMicrosecondsOverflow() { public void testInvalidMaxMicrosecondsOverflow() {
try { try {
Timestamps.toMicros(INVALID_MAX); Timestamps.toMicros(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -652,7 +651,7 @@ public class TimestampsTest {
public void testInvalidMaxMillisecondsOverflow() { public void testInvalidMaxMillisecondsOverflow() {
try { try {
Timestamps.toMillis(INVALID_MAX); Timestamps.toMillis(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -661,7 +660,7 @@ public class TimestampsTest {
public void testInvalidMaxSecondsOverflow() { public void testInvalidMaxSecondsOverflow() {
try { try {
Timestamps.toSeconds(INVALID_MAX); Timestamps.toSeconds(INVALID_MAX);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -670,7 +669,7 @@ public class TimestampsTest {
public void testInvalidMinNanosecondsOverflow() { public void testInvalidMinNanosecondsOverflow() {
try { try {
Timestamps.toNanos(INVALID_MIN); Timestamps.toNanos(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -679,7 +678,7 @@ public class TimestampsTest {
public void testInvalidMicrosecondsMinOverflow() { public void testInvalidMicrosecondsMinOverflow() {
try { try {
Timestamps.toMicros(INVALID_MIN); Timestamps.toMicros(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -688,7 +687,7 @@ public class TimestampsTest {
public void testInvalidMinMillisecondsOverflow() { public void testInvalidMinMillisecondsOverflow() {
try { try {
Timestamps.toMillis(INVALID_MIN); Timestamps.toMillis(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -697,7 +696,7 @@ public class TimestampsTest {
public void testOverInvalidMinSecondsflow() { public void testOverInvalidMinSecondsflow() {
try { try {
Timestamps.toSeconds(INVALID_MIN); Timestamps.toSeconds(INVALID_MIN);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -712,7 +711,7 @@ public class TimestampsTest {
public void testIllegalArgumentExceptionForMaxMicroseconds() { public void testIllegalArgumentExceptionForMaxMicroseconds() {
try { try {
Timestamps.fromMicros(Long.MAX_VALUE); Timestamps.fromMicros(Long.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -721,7 +720,7 @@ public class TimestampsTest {
public void testIllegalArgumentExceptionForMaxMilliseconds() { public void testIllegalArgumentExceptionForMaxMilliseconds() {
try { try {
Durations.fromMillis(Long.MAX_VALUE); Durations.fromMillis(Long.MAX_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -736,7 +735,7 @@ public class TimestampsTest {
public void testIllegalArgumentExceptionForMinMicroseconds() { public void testIllegalArgumentExceptionForMinMicroseconds() {
try { try {
Timestamps.fromMicros(Long.MIN_VALUE); Timestamps.fromMicros(Long.MIN_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -745,7 +744,7 @@ public class TimestampsTest {
public void testIllegalArgumentExceptionForMinMilliseconds() { public void testIllegalArgumentExceptionForMinMilliseconds() {
try { try {
Timestamps.fromMillis(Long.MIN_VALUE); Timestamps.fromMillis(Long.MIN_VALUE);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -802,7 +801,7 @@ public class TimestampsTest {
long timestampMaxSeconds = 253402300799L; long timestampMaxSeconds = 253402300799L;
try { try {
Timestamps.fromMillis((timestampMaxSeconds + 1) * MILLIS_PER_SECOND); Timestamps.fromMillis((timestampMaxSeconds + 1) * MILLIS_PER_SECOND);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }
@ -812,7 +811,7 @@ public class TimestampsTest {
long timestampMinSeconds = -62135596800L; long timestampMinSeconds = -62135596800L;
try { try {
Timestamps.fromMillis((timestampMinSeconds - 1) * MILLIS_PER_SECOND); Timestamps.fromMillis((timestampMinSeconds - 1) * MILLIS_PER_SECOND);
assertWithMessage("Expected an IllegalArgumentException to be thrown").fail(); fail("Expected an IllegalArgumentException to be thrown");
} catch (IllegalArgumentException expected) { } catch (IllegalArgumentException expected) {
} }
} }

Loading…
Cancel
Save