Merge JUnitBackport's expectThrows into assertThrows

More information: https://github.com/junit-team/junit5/issues/531

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=187034408
This commit is contained in:
cushon 2018-02-26 09:38:17 -08:00 committed by jianglai
parent f96a0b7da9
commit 606b470cd0
180 changed files with 1325 additions and 1381 deletions

View file

@ -18,7 +18,7 @@ import static google.registry.model.eppoutput.CheckData.ContactCheck.create;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceCheckFlowTestCase;
@ -79,7 +79,7 @@ public class ContactCheckFlowTest
@Test
public void testTooManyIds() throws Exception {
setEppInput("contact_check_51.xml");
EppException thrown = expectThrows(TooManyResourceChecksException.class, this::runFlow);
EppException thrown = assertThrows(TooManyResourceChecksException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View file

@ -20,7 +20,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowTestCase;
@ -71,7 +71,7 @@ public class ContactCreateFlowTest
public void testFailure_alreadyExists() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
ResourceAlreadyExistsException thrown =
expectThrows(ResourceAlreadyExistsException.class, this::runFlow);
assertThrows(ResourceAlreadyExistsException.class, this::runFlow);
assertThat(thrown)
.hasMessageThat()
.contains(
@ -89,7 +89,7 @@ public class ContactCreateFlowTest
public void testFailure_nonAsciiInIntAddress() throws Exception {
setEppInput("contact_create_hebrew_int.xml");
EppException thrown =
expectThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -97,7 +97,7 @@ public class ContactCreateFlowTest
public void testFailure_declineDisclosure() throws Exception {
setEppInput("contact_create_decline_disclosure.xml");
EppException thrown =
expectThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View file

@ -24,7 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableSet;
import google.registry.flows.EppException;
@ -74,7 +74,7 @@ public class ContactDeleteFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -83,7 +83,7 @@ public class ContactDeleteFlowTest
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -112,7 +112,7 @@ public class ContactDeleteFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(statusValue))
.build());
EppException thrown = expectThrows(exception, this::runFlow);
EppException thrown = assertThrows(exception, this::runFlow);
assertThat(thrown).hasMessageThat().contains(statusValue.getXmlName());
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -121,7 +121,7 @@ public class ContactDeleteFlowTest
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -148,7 +148,7 @@ public class ContactDeleteFlowTest
createTld("tld");
persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -157,7 +157,7 @@ public class ContactDeleteFlowTest
createTld("tld");
persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
EppException thrown = expectThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View file

@ -21,7 +21,7 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -166,7 +166,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
@Test
public void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -175,7 +175,7 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
public void testFailure_existedButWasDeleted() throws Exception {
persistContactResource(false);
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}

View file

@ -24,7 +24,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
@ -145,9 +145,10 @@ public class ContactTransferApproveFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
EppException thrown = expectThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_approve_with_authinfo.xml"));
EppException thrown =
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_approve_with_authinfo.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -155,7 +156,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -164,7 +165,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -173,7 +174,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -182,7 +183,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -191,7 +192,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -200,7 +201,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -209,7 +210,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_gainingClient() throws Exception {
setClientIdForFlow("NewRegistrar");
EppException thrown =
expectThrows(
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -218,7 +219,7 @@ public class ContactTransferApproveFlowTest
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
EppException thrown =
expectThrows(
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -228,7 +229,7 @@ public class ContactTransferApproveFlowTest
contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_approve.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -241,7 +242,7 @@ public class ContactTransferApproveFlowTest
contact = persistResource(
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_approve.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));

View file

@ -23,7 +23,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
@ -132,7 +132,7 @@ public class ContactTransferCancelFlowTest
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
EppException thrown =
expectThrows(
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_cancel_with_authinfo.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -142,7 +142,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -151,7 +151,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -160,7 +160,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -169,7 +169,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -178,7 +178,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -187,7 +187,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -196,7 +196,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar");
EppException thrown =
expectThrows(
assertThrows(
NotTransferInitiatorException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -206,7 +206,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
EppException thrown =
expectThrows(
assertThrows(
NotTransferInitiatorException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -217,7 +217,7 @@ public class ContactTransferCancelFlowTest
contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -228,7 +228,7 @@ public class ContactTransferCancelFlowTest
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));

View file

@ -20,7 +20,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.deleteResource;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
@ -145,7 +145,7 @@ public class ContactTransferQueryFlowTest
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
EppException thrown =
expectThrows(
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_query_with_authinfo.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -157,7 +157,7 @@ public class ContactTransferQueryFlowTest
// code above will write the wrong ROID into the file.
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
EppException thrown =
expectThrows(
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_query_with_roid.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -167,7 +167,7 @@ public class ContactTransferQueryFlowTest
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
EppException thrown =
expectThrows(
assertThrows(
NoTransferHistoryToQueryException.class,
() -> doFailingTest("contact_transfer_query.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -177,7 +177,7 @@ public class ContactTransferQueryFlowTest
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
EppException thrown =
expectThrows(
assertThrows(
NotAuthorizedToViewTransferException.class,
() -> doFailingTest("contact_transfer_query.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -188,7 +188,7 @@ public class ContactTransferQueryFlowTest
contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -198,7 +198,7 @@ public class ContactTransferQueryFlowTest
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();

View file

@ -23,7 +23,7 @@ import static google.registry.testing.DatastoreHelper.getOnlyPollMessage;
import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.EppException;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
@ -147,7 +147,7 @@ public class ContactTransferRejectFlowTest
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
EppException thrown =
expectThrows(
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_reject_with_authinfo.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -157,7 +157,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -166,7 +166,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -175,7 +175,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -184,7 +184,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -193,7 +193,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -202,7 +202,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
EppException thrown =
expectThrows(
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -211,7 +211,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_gainingClient() throws Exception {
setClientIdForFlow("NewRegistrar");
EppException thrown =
expectThrows(
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -220,7 +220,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
EppException thrown =
expectThrows(
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -230,7 +230,7 @@ public class ContactTransferRejectFlowTest
contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -241,7 +241,7 @@ public class ContactTransferRejectFlowTest
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));

View file

@ -29,7 +29,7 @@ import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@ -158,7 +158,7 @@ public class ContactTransferRequestFlowTest
@Test
public void testFailure_noAuthInfo() throws Exception {
EppException thrown =
expectThrows(
assertThrows(
MissingTransferRequestAuthInfoException.class,
() -> doFailingTest("contact_transfer_request_no_authinfo.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -174,7 +174,7 @@ public class ContactTransferRequestFlowTest
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
EppException thrown =
expectThrows(
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -225,7 +225,7 @@ public class ContactTransferRequestFlowTest
.build())
.build());
EppException thrown =
expectThrows(
assertThrows(
AlreadyPendingTransferException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -235,7 +235,7 @@ public class ContactTransferRequestFlowTest
public void testFailure_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar");
EppException thrown =
expectThrows(
assertThrows(
ObjectAlreadySponsoredException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -246,7 +246,7 @@ public class ContactTransferRequestFlowTest
contact =
persistResource(contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -257,7 +257,7 @@ public class ContactTransferRequestFlowTest
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
ResourceDoesNotExistException thrown =
expectThrows(
assertThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
@ -270,7 +270,7 @@ public class ContactTransferRequestFlowTest
persistResource(
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(
assertThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
@ -283,7 +283,7 @@ public class ContactTransferRequestFlowTest
persistResource(
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(
assertThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
@ -295,7 +295,7 @@ public class ContactTransferRequestFlowTest
contact =
persistResource(contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(
assertThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("pendingDelete");

View file

@ -22,7 +22,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistDeletedContact;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -258,7 +258,7 @@ public class ContactUpdateFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -267,7 +267,7 @@ public class ContactUpdateFlowTest
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThrows(ResourceDoesNotExistException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -276,7 +276,7 @@ public class ContactUpdateFlowTest
public void testFailure_statusValueNotClientSettable() throws Exception {
setEppInput("contact_update_prohibited_status.xml");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown = expectThrows(StatusNotClientSettableException.class, this::runFlow);
EppException thrown = assertThrows(StatusNotClientSettableException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -293,7 +293,7 @@ public class ContactUpdateFlowTest
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow);
EppException thrown = assertThrows(ResourceNotOwnedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -346,7 +346,7 @@ public class ContactUpdateFlowTest
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
EppException thrown =
expectThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
assertThrows(ResourceHasClientUpdateProhibitedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -358,7 +358,7 @@ public class ContactUpdateFlowTest
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -371,7 +371,7 @@ public class ContactUpdateFlowTest
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
assertThrows(ResourceStatusProhibitsOperationException.class, this::runFlow);
assertThat(thrown).hasMessageThat().contains("pendingDelete");
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -387,7 +387,7 @@ public class ContactUpdateFlowTest
setEppInput("contact_update_hebrew_int.xml");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown =
expectThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
assertThrows(BadInternationalizedPostalInfoException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -396,7 +396,7 @@ public class ContactUpdateFlowTest
setEppInput("contact_update_decline_disclosure.xml");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown =
expectThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@ -404,7 +404,7 @@ public class ContactUpdateFlowTest
public void testFailure_addRemoveSameValue() throws Exception {
setEppInput("contact_update_add_remove_same.xml");
persistActiveContact(getUniqueIdFromCommand());
EppException thrown = expectThrows(AddRemoveSameValueException.class, this::runFlow);
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}