mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
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:
parent
d5d29959b4
commit
9157930983
100 changed files with 3900 additions and 3192 deletions
|
@ -17,6 +17,7 @@ package google.registry.tools;
|
|||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import google.registry.model.registry.Registry;
|
||||
|
@ -83,43 +84,80 @@ public class CreateAnchorTenantCommandTest
|
|||
|
||||
@Test
|
||||
public void testFailure_mainParameter() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--tld=tld", "--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--tld=tld",
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingClientId() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unknownFlag() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--foo=bar", "--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--foo=bar",
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingDomainName() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_missingContact() throws Exception {
|
||||
thrown.expect(ParameterException.class);
|
||||
runCommandForced("--client=NewRegistrar", "--superuser",
|
||||
"--reason=anchor-tenant-test", "--domain_name=example.tld", "foo");
|
||||
assertThrows(
|
||||
ParameterException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--superuser",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--domain_name=example.tld",
|
||||
"foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_notAsSuperuser() throws Exception {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
runCommandForced("--client=NewRegistrar",
|
||||
"--reason=anchor-tenant-test", "--contact=jd1234", "--domain_name=example.tld");
|
||||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() ->
|
||||
runCommandForced(
|
||||
"--client=NewRegistrar",
|
||||
"--reason=anchor-tenant-test",
|
||||
"--contact=jd1234",
|
||||
"--domain_name=example.tld"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue