Automatically refactor more exception testing to use new JUnit rules

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=179072309
This commit is contained in:
mcilwain 2017-12-14 11:40:04 -08:00 committed by Ben McIlwain
parent d5d29959b4
commit 9157930983
100 changed files with 3900 additions and 3192 deletions

View file

@ -20,6 +20,7 @@ import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.expectThrows;
import google.registry.model.registry.Registry;
import google.registry.model.registry.label.ReservedList;
@ -47,9 +48,11 @@ public class DeleteReservedListCommandTest extends CommandTestCase<DeleteReserve
public void testFailure_whenReservedListDoesNotExist() throws Exception {
String expectedError =
"Cannot delete the reserved list doesntExistReservedList because it doesn't exist.";
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage(expectedError);
runCommandForced("--name=doesntExistReservedList");
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
() -> runCommandForced("--name=doesntExistReservedList"));
assertThat(thrown).hasMessageThat().contains(expectedError);
}
@Test