arnabnandy7 commented on code in PR #23307:
URL: https://github.com/apache/kafka/pull/23307#discussion_r3921996955
##########
streams/src/test/java/org/apache/kafka/streams/internals/ApiUtilsTest.java:
##########
@@ -36,52 +35,48 @@ public class ApiUtilsTest {
private static final long MAX_ACCEPTABLE_DAYS_FOR_DURATION_TO_MILLIS =
106751991167L;
@Test
- public void shouldThrowNullPointerExceptionForNullDuration() {
+ public void shouldThrowIllegalArgumentExceptionForNullDuration() {
final String nullDurationPrefix =
prepareMillisCheckFailMsgPrefix(null, "nullDuration");
- try {
- validateMillisecondDuration(null, nullDurationPrefix);
- fail("Expected exception when null passed to duration.");
- } catch (final IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString(nullDurationPrefix));
- }
+ final IllegalArgumentException e = assertThrows(
+ IllegalArgumentException.class,
+ () -> validateMillisecondDuration(null, nullDurationPrefix)
+ );
+ assertTrue(e.getMessage().contains(nullDurationPrefix));
}
@Test
public void shouldThrowArithmeticExceptionForMaxDuration() {
final Duration maxDurationInDays =
Duration.ofDays(MAX_ACCEPTABLE_DAYS_FOR_DURATION);
final String maxDurationPrefix =
prepareMillisCheckFailMsgPrefix(maxDurationInDays, "maxDuration");
- try {
- validateMillisecondDuration(maxDurationInDays, maxDurationPrefix);
- fail("Expected exception when maximum days passed for duration,
because of long overflow");
- } catch (final IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString(maxDurationPrefix));
- }
+ final IllegalArgumentException e = assertThrows(
+ IllegalArgumentException.class,
+ () -> validateMillisecondDuration(maxDurationInDays,
maxDurationPrefix)
+ );
+ assertTrue(e.getMessage().contains(maxDurationPrefix));
}
@Test
- public void shouldThrowNullPointerExceptionForNullInstant() {
+ public void shouldThrowIllegalArgumentExceptionForNullInstant() {
final String nullInstantPrefix = prepareMillisCheckFailMsgPrefix(null,
"nullInstant");
- try {
- validateMillisecondInstant(null, nullInstantPrefix);
- fail("Expected exception when null value passed for instant.");
- } catch (final IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString(nullInstantPrefix));
- }
+ final IllegalArgumentException e = assertThrows(
+ IllegalArgumentException.class,
+ () -> validateMillisecondInstant(null, nullInstantPrefix)
+ );
+ assertTrue(e.getMessage().contains(nullInstantPrefix));
}
@Test
public void shouldThrowArithmeticExceptionForMaxInstant() {
Review Comment:
done @chia7712
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]