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

@ -42,7 +42,8 @@ public final class TlsCredentialsTest {
@Test
public void testProvideClientCertificateHash_missing() {
thrown.expect(BadRequestException.class, "Missing header: X-SSL-Certificate");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-SSL-Certificate");
HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideClientCertificateHash(req);
}
@ -57,7 +58,8 @@ public final class TlsCredentialsTest {
@Test
public void testProvideRequestedServername_missing() {
thrown.expect(BadRequestException.class, "Missing header: X-Requested-Servername-SNI");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-Requested-Servername-SNI");
HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideRequestedServername(req);
}

View file

@ -66,8 +66,8 @@ public class ContactCreateFlowTest
@Test
public void testFailure_alreadyExists() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(
ResourceAlreadyExistsException.class,
thrown.expect(ResourceAlreadyExistsException.class);
thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -69,18 +69,16 @@ public class ContactDeleteFlowTest
@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 {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -90,7 +88,8 @@ public class ContactDeleteFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(statusValue))
.build());
thrown.expect(exception, statusValue.getXmlName());
thrown.expect(exception);
thrown.expectMessage(statusValue.getXmlName());
runFlow();
}

View file

@ -163,18 +163,16 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
@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 {
persistContactResource(false);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}

View file

@ -206,9 +206,8 @@ public class ContactTransferApproveFlowTest
public void testFailure_deletedContact() throws Exception {
contact = persistResource(
contact.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("contact_transfer_approve.xml");
}
@ -217,9 +216,8 @@ public class ContactTransferApproveFlowTest
deleteResource(contact);
contact = persistResource(
contact.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("contact_transfer_approve.xml");
}

View file

@ -190,18 +190,16 @@ public class ContactTransferCancelFlowTest
public void testFailure_deletedContact() throws Exception {
contact = persistResource(
contact.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("contact_transfer_cancel.xml");
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_cancel.xml");
}

View file

@ -169,18 +169,16 @@ public class ContactTransferQueryFlowTest
public void testFailure_deletedContact() throws Exception {
contact = persistResource(
contact.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("contact_transfer_query.xml");
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_query.xml");
}

View file

@ -205,18 +205,16 @@ public class ContactTransferRejectFlowTest
public void testFailure_deletedContact() throws Exception {
contact = persistResource(
contact.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("contact_transfer_reject.xml");
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_reject.xml");
}

View file

@ -223,18 +223,16 @@ public class ContactTransferRequestFlowTest
public void testFailure_deletedContact() throws Exception {
contact = persistResource(
contact.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("contact_transfer_request.xml");
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_request.xml");
}
@ -242,7 +240,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_clientTransferProhibited() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "clientTransferProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("contact_transfer_request.xml");
}
@ -250,7 +249,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_serverTransferProhibited() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverTransferProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("contact_transfer_request.xml");
}
@ -258,7 +258,8 @@ public class ContactTransferRequestFlowTest
public void testFailure_pendingDelete() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("contact_transfer_request.xml");
}

View file

@ -253,18 +253,16 @@ public class ContactUpdateFlowTest
@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 {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -349,7 +347,8 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
}
@ -359,7 +358,8 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
}

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();
}

View file

@ -170,9 +170,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testFailure_superordinateMissing() throws Exception {
setEppHostCreateInput("ns1.example.tld", null);
createTld("tld");
thrown.expect(
SuperordinateDomainDoesNotExistException.class,
"(example.tld)");
thrown.expect(SuperordinateDomainDoesNotExistException.class);
thrown.expectMessage("(example.tld)");
runFlow();
}
@ -186,9 +185,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
clock.advanceOneMilli();
thrown.expect(
SuperordinateDomainInPendingDeleteException.class,
"Superordinate domain for this hostname is in pending delete");
thrown.expect(SuperordinateDomainInPendingDeleteException.class);
thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
runFlow();
}
@ -196,8 +194,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testFailure_alreadyExists() throws Exception {
setEppHostCreateInput("ns1.example.tld", null);
persistActiveHost(getUniqueIdFromCommand());
thrown.expect(
ResourceAlreadyExistsException.class,
thrown.expect(ResourceAlreadyExistsException.class);
thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow();
}
@ -212,7 +210,8 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppHostCreateInput("ns1.çauçalito.みんな", null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.xn--q9jyb4c");
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.xn--q9jyb4c");
runFlow();
}

View file

@ -81,14 +81,16 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class, "(ns1.example.tld)");
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow();
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class, "(ns1.example.tld)");
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow();
}
@ -98,7 +100,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
newHostResource("ns1.example.tld").asBuilder()
.setStatusValues(ImmutableSet.of(statusValue))
.build());
thrown.expect(exception, statusValue.getXmlName());
thrown.expect(exception);
thrown.expectMessage(statusValue.getXmlName());
runFlow();
}
@ -268,7 +271,8 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
}

View file

@ -143,9 +143,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@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();
}
@ -153,9 +152,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
public void testFailure_existedButWasDeleted() throws Exception {
persistResource(
persistHostResource().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();
}
@ -169,7 +167,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
}

View file

@ -759,9 +759,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_superordinateMissing() throws Exception {
createTld("tld");
persistActiveHost(oldHostName());
thrown.expect(
SuperordinateDomainDoesNotExistException.class,
"(example.tld)");
thrown.expect(SuperordinateDomainDoesNotExistException.class);
thrown.expectMessage("(example.tld)");
runFlow();
}
@ -781,35 +780,31 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build());
persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
thrown.expect(
SuperordinateDomainInPendingDeleteException.class,
"Superordinate domain for this hostname is in pending delete");
thrown.expect(SuperordinateDomainInPendingDeleteException.class);
thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
runFlow();
}
@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_neverExisted_updateWithoutNameChange() throws Exception {
setEppInput("host_update_name_unchanged.xml");
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 {
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
}
@ -819,7 +814,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
clock.advanceOneMilli();
setEppHostUpdateInput("ns1.example.tld", "ns1.example.tld", null, null);
thrown.expect(HostAlreadyExistsException.class, "ns1.example.tld");
thrown.expect(HostAlreadyExistsException.class);
thrown.expectMessage("ns1.example.tld");
runFlow();
}
@ -828,7 +824,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistActiveHost("ns2.example.tld");
thrown.expect(HostAlreadyExistsException.class, "ns2.example.tld");
thrown.expect(HostAlreadyExistsException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
}
@ -850,7 +847,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
@Test
public void testFailure_referToNonPunyCodedHostname() throws Exception {
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
}
@ -858,7 +856,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_renameToNonPunyCodedHostname() throws Exception {
persistActiveHost("ns1.sausalito.tld");
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class, "expected ns1.xn--aualito-txac.tld");
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
}
@ -977,7 +976,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "serverUpdateProhibited");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
}
@ -989,7 +989,8 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class, "pendingDelete");
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
}