Get rid of custom ExceptionRule methods

The only remaining methods on ExceptionRule after this are methods that
also exist on ExpectedException, which will allow us to, in the next CL,
swap out the one for the other and then run the automated refactoring to
turn it all into assertThrows/expectThrows.

Note that there were some assertions about root causes that couldn't
easily be turned into ExpectedException invocations, so I simply
converted them directly to usages of assertThrows/expectThrows.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=178623431
This commit is contained in:
mcilwain 2017-12-11 08:47:27 -08:00 committed by jianglai
parent 68a26f5b6e
commit b825a2b5a8
144 changed files with 1176 additions and 894 deletions

View file

@ -253,7 +253,8 @@ public class DomainAllocateFlowTest
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
}
@ -267,7 +268,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net"))
.build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234");
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlowAsSuperuser();
}
@ -311,7 +313,8 @@ public class DomainAllocateFlowTest
"reserved",
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
}
@ -363,7 +366,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net", "ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
}
@ -381,7 +385,8 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns4.example.net", "ns2.example.net", "ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
}

View file

@ -1055,7 +1055,8 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
thrown.expect(LinkedResourcesDoNotExistException.class, "(ns2.example.net)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.net)");
runFlow();
}
@ -1064,7 +1065,8 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net");
persistActiveContact("jd1234");
thrown.expect(LinkedResourcesDoNotExistException.class, "(sh8013)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
}
@ -1562,7 +1564,8 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234");
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow();
}
@ -1572,7 +1575,8 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1633,7 +1637,8 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1691,7 +1696,8 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1710,7 +1716,8 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}

View file

@ -123,9 +123,8 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -135,9 +134,8 @@ public class DomainApplicationDeleteFlowTest
.setRepoId("1-TLD")
.setDeletionTime(clock.nowUtc().minusSeconds(1))
.build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -261,9 +261,8 @@ public class DomainApplicationInfoFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -275,9 +274,8 @@ public class DomainApplicationInfoFlowTest
.setDeletionTime(clock.nowUtc().minusDays(1))
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -417,9 +417,8 @@ public class DomainApplicationUpdateFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
persistReferencedEntities();
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -427,9 +426,8 @@ public class DomainApplicationUpdateFlowTest
public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setDeletionTime(START_OF_TIME).build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -448,7 +446,8 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
}
@ -480,9 +479,8 @@ public class DomainApplicationUpdateFlowTest
persistActiveContact("sh8013");
persistActiveContact("mak21");
persistNewApplication();
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(ns2.example.tld)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.tld)");
runFlow();
}
@ -492,9 +490,8 @@ public class DomainApplicationUpdateFlowTest
persistActiveHost("ns2.example.tld");
persistActiveContact("mak21");
persistNewApplication();
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(sh8013)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
}
@ -749,7 +746,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.tld");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
}
@ -827,7 +825,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.tld");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
}
@ -846,7 +845,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class, "ns2.example.tld");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
}

View file

@ -637,7 +637,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build());
setEppInput("domain_create_lrp.xml");
persistContactsAndHosts();
thrown.expect(InvalidLrpTokenException.class, "Invalid limited registration period token");
thrown.expect(InvalidLrpTokenException.class);
thrown.expectMessage("Invalid limited registration period token");
runFlow();
assertThat(ofy().load().entity(token).now().getRedemptionHistoryEntry()).isNull();
}
@ -648,7 +649,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistContactsAndHosts();
thrown.expect(InvalidLrpTokenException.class, "Invalid limited registration period token");
thrown.expect(InvalidLrpTokenException.class);
thrown.expectMessage("Invalid limited registration period token");
runFlow();
}
@ -1043,9 +1045,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(ns2.example.net)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.net)");
runFlow();
}
@ -1058,9 +1059,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"ns2.example.net");
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("ns2.example.net");
runFlow();
}
@ -1095,9 +1095,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net");
persistActiveContact("jd1234");
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(sh8013)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
}
@ -1110,9 +1109,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"jd1234");
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("jd1234");
runFlow();
}
@ -1708,7 +1706,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build());
thrown.expect(RegistrantNotAllowedException.class, "jd1234");
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow();
}
@ -1718,7 +1717,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1785,7 +1785,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1800,7 +1801,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList(
"reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.net:ns2.example.net"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class, "example.tld");
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow();
}
@ -1849,7 +1851,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1867,7 +1870,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED,"
+ "ns2.example.net:ns3.example.net:ns4.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns1.example.net");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
}
@ -1887,7 +1891,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"lol,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class, "example.tld");
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow();
}

View file

@ -651,18 +651,16 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -721,7 +719,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientDeleteProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientDeleteProhibited");
runFlow();
}
@ -730,7 +729,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverDeleteProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverDeleteProhibited");
runFlow();
}
@ -739,7 +739,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
}

View file

@ -373,9 +373,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -384,9 +383,8 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
persistResource(newDomainResource("example.tld").asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -410,32 +410,32 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@Test
public void testFailure_clientRenewProhibited() throws Exception {
persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientRenewProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientRenewProhibited");
runFlow();
}
@Test
public void testFailure_serverRenewProhibited() throws Exception {
persistDomain(StatusValue.SERVER_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverRenewProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverRenewProhibited");
runFlow();
}
@ -446,7 +446,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
}
@ -574,7 +575,8 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z"))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingTransfer");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingTransfer");
runFlow();
}

View file

@ -340,9 +340,8 @@ public class DomainRestoreRequestFlowTest extends
@Test
public void testFailure_doesNotExist() throws Exception {
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -480,16 +480,16 @@ public class DomainTransferApproveFlowTest
public void testFailure_deletedDomain() throws Exception {
persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml");
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml");
}

View file

@ -285,18 +285,16 @@ public class DomainTransferCancelFlowTest
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml");
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml");
}

View file

@ -207,18 +207,16 @@ public class DomainTransferQueryFlowTest
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml");
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml");
}

View file

@ -268,18 +268,16 @@ public class DomainTransferRejectFlowTest
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml");
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml");
}

View file

@ -1224,9 +1224,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_request.xml");
}
@ -1238,7 +1237,8 @@ public class DomainTransferRequestFlowTest
ImmutableMap.of("YEARS", "1", "DOMAIN", "--invalid", "EXDATE", "2002-09-08T22:00:00.0Z"));
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
assertTransactionalFlow(true);
thrown.expect(ResourceDoesNotExistException.class, "(--invalid)");
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(--invalid)");
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
}
@ -1246,9 +1246,8 @@ public class DomainTransferRequestFlowTest
public void testFailure_nonexistentDomain() throws Exception {
createTld("tld");
contact = persistActiveContact("jd1234");
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", "example.tld"));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", "example.tld"));
doFailingTest("domain_transfer_request.xml");
}
@ -1264,7 +1263,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientTransferProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("domain_transfer_request.xml");
}
@ -1273,7 +1273,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverTransferProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("domain_transfer_request.xml");
}
@ -1282,7 +1283,8 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("domain_transfer_request.xml");
}

View file

@ -822,9 +822,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
@Test
public void testFailure_neverExisted() throws Exception {
persistReferencedEntities();
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -832,9 +831,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities();
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -844,9 +842,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveContact("sh8013");
persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(ns2.example.foo)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.foo)");
runFlow();
}
@ -856,9 +853,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveHost("ns2.example.foo");
persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(
LinkedResourcesDoNotExistException.class,
"(sh8013)");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
}
@ -956,7 +952,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
}
@ -968,7 +965,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
}
@ -1098,9 +1096,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"mak21");
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("mak21");
runFlow();
}
@ -1116,9 +1113,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"ns2.example.foo");
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
}
@ -1256,7 +1252,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
}
@ -1317,7 +1314,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
}
@ -1351,7 +1349,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setReservedLists(
persistReservedList("reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class, "ns2.example.foo");
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
}
@ -1368,7 +1367,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class, "ns2.example.foo");
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
}