mirror of
https://github.com/google/nomulus.git
synced 2025-05-20 19:29:35 +02:00
Automatically refactor more exception testing to use new JUnit rules
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=179072309
This commit is contained in:
parent
d5d29959b4
commit
9157930983
100 changed files with 3900 additions and 3192 deletions
|
@ -23,6 +23,8 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
|
|||
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.JUnitBackports.assertThrows;
|
||||
import static google.registry.testing.JUnitBackports.expectThrows;
|
||||
|
||||
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
|
||||
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
|
||||
|
@ -142,73 +144,76 @@ public class ContactTransferApproveFlowTest
|
|||
contact.asBuilder()
|
||||
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
|
||||
.build());
|
||||
thrown.expect(BadAuthInfoForResourceException.class);
|
||||
doFailingTest("contact_transfer_approve_with_authinfo.xml");
|
||||
assertThrows(
|
||||
BadAuthInfoForResourceException.class,
|
||||
() -> doFailingTest("contact_transfer_approve_with_authinfo.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_neverBeenTransferred() throws Exception {
|
||||
changeTransferStatus(null);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_clientApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_clientRejected() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_clientCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverApproved() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_APPROVED);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_serverCancelled() throws Exception {
|
||||
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
|
||||
thrown.expect(NotPendingTransferException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_gainingClient() throws Exception {
|
||||
setClientIdForFlow("NewRegistrar");
|
||||
thrown.expect(ResourceNotOwnedException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_unrelatedClient() throws Exception {
|
||||
setClientIdForFlow("ClientZ");
|
||||
thrown.expect(ResourceNotOwnedException.class);
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
assertThrows(
|
||||
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_approve.xml"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_deletedContact() throws Exception {
|
||||
contact = persistResource(
|
||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
thrown.expect(ResourceDoesNotExistException.class);
|
||||
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
ResourceDoesNotExistException thrown =
|
||||
expectThrows(
|
||||
ResourceDoesNotExistException.class,
|
||||
() -> doFailingTest("contact_transfer_approve.xml"));
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -216,9 +221,11 @@ public class ContactTransferApproveFlowTest
|
|||
deleteResource(contact);
|
||||
contact = persistResource(
|
||||
contact.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
|
||||
thrown.expect(ResourceDoesNotExistException.class);
|
||||
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
doFailingTest("contact_transfer_approve.xml");
|
||||
ResourceDoesNotExistException thrown =
|
||||
expectThrows(
|
||||
ResourceDoesNotExistException.class,
|
||||
() -> doFailingTest("contact_transfer_approve.xml"));
|
||||
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue