ItsValidateCommentTest: Migrate from try-catch-fail to assertThrows

Change-Id: Ie6c57b7dc6870d23202bf8ef54966ab3e18a7b8d
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
index d29457e..6c61002 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
@@ -13,6 +13,8 @@
 // limitations under the License.
 package com.googlesource.gerrit.plugins.its.base.validation;
 
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.easymock.EasyMock.expect;
 
 import com.google.gerrit.extensions.annotations.PluginName;
@@ -111,14 +113,9 @@
 
     replayMocks();
 
-    try {
-      ivc.onCommitReceived(event);
-      fail("onCommitReceived did not throw any exception");
-    } catch (CommitValidationException e) {
-      assertTrue(
-          "Message of thrown CommitValidationException does not " + "contain 'Missing issue'",
-          e.getMessage().contains("Missing issue"));
-    }
+    CommitValidationException thrown =
+        assertThrows(CommitValidationException.class, () -> ivc.onCommitReceived(event));
+    assertThat(thrown).hasMessageThat().contains("Missing issue");
   }
 
   public void testOnlySkipMatching() throws CommitValidationException {
@@ -242,14 +239,9 @@
 
     replayMocks();
 
-    try {
-      ivc.onCommitReceived(event);
-      fail("onCommitReceived did not throw any exception");
-    } catch (CommitValidationException e) {
-      assertTrue(
-          "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
-          e.getMessage().contains("Non-existing"));
-    }
+    CommitValidationException thrown =
+        assertThrows(CommitValidationException.class, () -> ivc.onCommitReceived(event));
+    assertThat(thrown).hasMessageThat().contains("Non-existing");
   }
 
   public void testSuggestedMatchingMultiple() throws CommitValidationException, IOException {
@@ -363,14 +355,9 @@
 
     replayMocks();
 
-    try {
-      ivc.onCommitReceived(event);
-      fail("onCommitReceived did not throw any exception");
-    } catch (CommitValidationException e) {
-      assertTrue(
-          "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
-          e.getMessage().contains("Non-existing"));
-    }
+    CommitValidationException thrown =
+        assertThrows(CommitValidationException.class, () -> ivc.onCommitReceived(event));
+    assertThat(thrown).hasMessageThat().contains("Non-existing");
   }
 
   public void testSuggestedMatchingMultipleSomeNonExsting()
@@ -431,14 +418,9 @@
 
     replayMocks();
 
-    try {
-      ivc.onCommitReceived(event);
-      fail("onCommitReceived did not throw any exception");
-    } catch (CommitValidationException e) {
-      assertTrue(
-          "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
-          e.getMessage().contains("Non-existing"));
-    }
+    CommitValidationException thrown =
+        assertThrows(CommitValidationException.class, () -> ivc.onCommitReceived(event));
+    assertThat(thrown).hasMessageThat().contains("Non-existing");
   }
 
   public void testSuggestedMatchingMultipleIOExceptionIsNonExsting()