MutableTagsTest: Migrate from try-catch-fail to assertThrows

Change-Id: I64d3e012e4f95753651bea5aa911e630f624183d
This commit is contained in:
David Pursehouse
2019-05-22 20:33:55 +09:00
parent 98f1fbb5c6
commit e3c974a3d8

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.server.logging;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assert_;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -166,11 +166,7 @@ public class MutableTagsTest {
}
private void assertNullPointerException(String expectedMessage, Runnable r) {
try {
r.run();
assert_().fail("expected NullPointerException");
} catch (NullPointerException e) {
assertThat(e.getMessage()).isEqualTo(expectedMessage);
}
NullPointerException thrown = assertThrows(NullPointerException.class, () -> r.run());
assertThat(thrown).hasMessageThat().isEqualTo(expectedMessage);
}
}