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,6 +14,8 @@
package google.registry.tools;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.beust.jcommander.ParameterException;
import google.registry.testing.DeterministicStringGenerator;
import org.junit.Before;
@ -58,30 +60,31 @@ public class CreateContactCommandTest extends EppToolCommandTestCase<CreateConta
@Test
public void testFailure_missingClientId() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced();
assertThrows(ParameterException.class, () -> runCommandForced());
}
@Test
public void testFailure_tooManyStreetLines() throws Exception {
thrown.expect(IllegalArgumentException.class);
runCommandForced(
"--client=NewRegistrar",
"--street=\"123 Example Dr.\"",
"--street=\"Floor 3\"",
"--street=\"Suite 100\"",
"--street=\"Office 1\"");
assertThrows(
IllegalArgumentException.class,
() ->
runCommandForced(
"--client=NewRegistrar",
"--street=\"123 Example Dr.\"",
"--street=\"Floor 3\"",
"--street=\"Suite 100\"",
"--street=\"Office 1\""));
}
@Test
public void testFailure_badPhone() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--phone=3");
assertThrows(
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--phone=3"));
}
@Test
public void testFailure_badFax() throws Exception {
thrown.expect(ParameterException.class);
runCommandForced("--client=NewRegistrar", "--fax=3");
assertThrows(
ParameterException.class, () -> runCommandForced("--client=NewRegistrar", "--fax=3"));
}
}