Migrate final try/catch test assertions to use assert/expectThrows

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182091814
This commit is contained in:
mcilwain 2018-01-16 12:08:08 -08:00 committed by Ben McIlwain
parent fe7cc4f782
commit c416b3892d
17 changed files with 124 additions and 172 deletions

View file

@ -15,7 +15,6 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static google.registry.testing.DatastoreHelper.createTlds;
@ -175,13 +174,12 @@ public class CreateReservedListCommandTest extends
}
private void runNameTestExpectedFailure(String name, String expectedErrorMsg) throws Exception {
try {
runCommandForced("--name=" + name, "--input=" + reservedTermsPath);
assertWithMessage("Expected IllegalArgumentException to be thrown").fail();
} catch (IllegalArgumentException e) {
assertThat(ReservedList.get(name)).isEmpty();
assertThat(e).hasMessageThat().isEqualTo(expectedErrorMsg);
}
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
() -> runCommandForced("--name=" + name, "--input=" + reservedTermsPath));
assertThat(ReservedList.get(name)).isEmpty();
assertThat(thrown).hasMessageThat().isEqualTo(expectedErrorMsg);
}
private void runNameTestWithOverride(String name) throws Exception {