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

@ -14,7 +14,10 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.beust.jcommander.ParameterException;
import org.junit.Test;
@ -43,18 +46,18 @@ public class CreateHostCommandTest extends EppToolCommandTestCase<CreateHostComm
@Test
public void testFailure_missingHost() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar");
assertThrows(ParameterException.class, () -> runCommandForced("--client=NewRegistrar"));
}
@Test
public void testFailure_invalidIpAddress() throws Exception {
createTld("tld");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("'a.b.c.d' is not an IP string literal.");
runCommandForced(
"--client=NewRegistrar",
"--host=example.tld",
"--addresses=a.b.c.d");
IllegalArgumentException thrown =
expectThrows(
IllegalArgumentException.class,
() ->
runCommandForced(
"--client=NewRegistrar", "--host=example.tld", "--addresses=a.b.c.d"));
assertThat(thrown).hasMessageThat().contains("'a.b.c.d' is not an IP string literal.");
}
}