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:
mcilwain 2017-12-14 11:40:04 -08:00 committed by Ben McIlwain
parent d5d29959b4
commit 9157930983
100 changed files with 3900 additions and 3192 deletions

View file

@ -39,7 +39,6 @@ import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -53,9 +52,6 @@ public class EppCommitLogsTest extends ShardableTestCase {
.withTaskQueue()
.build();
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule
public final InjectRule inject = new InjectRule();

View file

@ -17,14 +17,13 @@ package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.flows.EppXmlTransformer.unmarshal;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.util.ResourceUtils.readResourceBytes;
import google.registry.model.eppinput.EppInput;
import google.registry.model.eppoutput.EppOutput;
import google.registry.testing.ShardableTestCase;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -32,9 +31,6 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class EppXmlTransformerTest extends ShardableTestCase {
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testUnmarshalingEppInput() throws Exception {
EppInput input = unmarshal(
@ -44,8 +40,11 @@ public class EppXmlTransformerTest extends ShardableTestCase {
@Test
public void testUnmarshalingWrongClassThrows() throws Exception {
thrown.expect(ClassCastException.class);
EppXmlTransformer.unmarshal(
EppOutput.class, readResourceBytes(getClass(), "testdata/contact_info.xml").read());
assertThrows(
ClassCastException.class,
() ->
EppXmlTransformer.unmarshal(
EppOutput.class,
readResourceBytes(getClass(), "testdata/contact_info.xml").read()));
}
}

View file

@ -15,6 +15,7 @@
package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -38,7 +39,6 @@ import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -50,10 +50,6 @@ public class ExtensionManagerTest {
public final AppEngineRule appEngine = AppEngineRule.builder()
.withDatastore()
.build();
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Test
public void testDuplicateExtensionsForbidden() throws Exception {
ExtensionManager manager = new TestInstanceBuilder()
@ -65,8 +61,7 @@ public class ExtensionManagerTest {
MetadataExtension.class)
.build();
manager.register(MetadataExtension.class, LaunchCreateExtension.class);
thrown.expect(UnsupportedRepeatedExtensionException.class);
manager.validate();
assertThrows(UnsupportedRepeatedExtensionException.class, () -> manager.validate());
}
@Test
@ -97,8 +92,7 @@ public class ExtensionManagerTest {
.setSuppliedExtensions(FeeInfoCommandExtensionV06.class)
.build();
manager.register(FeeInfoCommandExtensionV06.class);
thrown.expect(UndeclaredServiceExtensionException.class);
manager.validate();
assertThrows(UndeclaredServiceExtensionException.class, () -> manager.validate());
}
@Test
@ -131,8 +125,7 @@ public class ExtensionManagerTest {
.setSuppliedExtensions(MetadataExtension.class)
.build();
manager.register(MetadataExtension.class);
thrown.expect(OnlyToolCanPassMetadataException.class);
manager.validate();
assertThrows(OnlyToolCanPassMetadataException.class, () -> manager.validate());
}
@Test
@ -156,8 +149,7 @@ public class ExtensionManagerTest {
.setIsSuperuser(false)
.build();
manager.register(DomainTransferRequestSuperuserExtension.class);
thrown.expect(UnauthorizedForSuperuserExtensionException.class);
manager.validate();
assertThrows(UnauthorizedForSuperuserExtensionException.class, () -> manager.validate());
}
@Test
@ -169,8 +161,7 @@ public class ExtensionManagerTest {
.setIsSuperuser(true)
.build();
manager.register(DomainTransferRequestSuperuserExtension.class);
thrown.expect(UnauthorizedForSuperuserExtensionException.class);
manager.validate();
assertThrows(UnauthorizedForSuperuserExtensionException.class, () -> manager.validate());
}
@Test
@ -180,8 +171,7 @@ public class ExtensionManagerTest {
.setDeclaredUris()
.setSuppliedExtensions(LaunchCreateExtension.class)
.build();
thrown.expect(UnimplementedExtensionException.class);
manager.validate();
assertThrows(UnimplementedExtensionException.class, () -> manager.validate());
}
/** A builder for a test-ready {@link ExtensionManager} instance. */

View file

@ -63,7 +63,6 @@ import java.util.Map;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -87,9 +86,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
.withTaskQueue()
.build();
@Rule
public final ExpectedException thrown = ExpectedException.none();
@Rule
public final InjectRule inject = new InjectRule();

View file

@ -19,6 +19,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.LogsSubject.assertAboutLogs;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
@ -131,8 +132,7 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
@Test
public void testRequiresLogin() throws Exception {
sessionMetadata.setClientId(null);
thrown.expect(NotLoggedInException.class);
runFlow();
assertThrows(NotLoggedInException.class, () -> runFlow());
}
/**

View file

@ -15,37 +15,34 @@
package google.registry.flows;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.JUnitBackports.expectThrows;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import google.registry.request.HttpException.BadRequestException;
import javax.servlet.http.HttpServletRequest;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
/** Unit tests for {@link TlsCredentials}. */
@RunWith(JUnit4.class)
public final class TlsCredentialsTest {
@Rule public final ExpectedException thrown = ExpectedException.none();
@Test
public void testProvideClientCertificateHash() {
HttpServletRequest req = mock(HttpServletRequest.class);
when(req.getHeader("X-SSL-Certificate")).thenReturn("data");
assertThat(TlsCredentials.EppTlsModule.provideClientCertificateHash(req))
.isEqualTo("data");
assertThat(TlsCredentials.EppTlsModule.provideClientCertificateHash(req)).isEqualTo("data");
}
@Test
public void testProvideClientCertificateHash_missing() {
thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-SSL-Certificate");
HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideClientCertificateHash(req);
BadRequestException thrown =
expectThrows(
BadRequestException.class,
() -> TlsCredentials.EppTlsModule.provideClientCertificateHash(req));
assertThat(thrown).hasMessageThat().contains("Missing header: X-SSL-Certificate");
}
@Test
@ -58,10 +55,12 @@ public final class TlsCredentialsTest {
@Test
public void testProvideRequestedServername_missing() {
thrown.expect(BadRequestException.class);
thrown.expectMessage("Missing header: X-Requested-Servername-SNI");
HttpServletRequest req = mock(HttpServletRequest.class);
TlsCredentials.EppTlsModule.provideRequestedServername(req);
BadRequestException thrown =
expectThrows(
BadRequestException.class,
() -> TlsCredentials.EppTlsModule.provideRequestedServername(req));
assertThat(thrown).hasMessageThat().contains("Missing header: X-Requested-Servername-SNI");
}
}

View file

@ -17,6 +17,7 @@ package google.registry.flows.contact;
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.JUnitBackports.assertThrows;
import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException;
@ -76,8 +77,7 @@ public class ContactCheckFlowTest
@Test
public void testTooManyIds() throws Exception {
setEppInput("contact_check_51.xml");
thrown.expect(TooManyResourceChecksException.class);
runFlow();
assertThrows(TooManyResourceChecksException.class, () -> runFlow());
}
@Test

View file

@ -14,10 +14,13 @@
package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import google.registry.flows.ResourceFlowTestCase;
import google.registry.flows.contact.ContactFlowUtils.BadInternationalizedPostalInfoException;
@ -66,10 +69,12 @@ public class ContactCreateFlowTest
@Test
public void testFailure_alreadyExists() throws Exception {
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(ResourceAlreadyExistsException.class);
thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow();
ResourceAlreadyExistsException thrown =
expectThrows(ResourceAlreadyExistsException.class, () -> runFlow());
assertThat(thrown)
.hasMessageThat()
.contains(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
@Test
@ -81,15 +86,13 @@ public class ContactCreateFlowTest
@Test
public void testFailure_nonAsciiInIntAddress() throws Exception {
setEppInput("contact_create_hebrew_int.xml");
thrown.expect(BadInternationalizedPostalInfoException.class);
runFlow();
assertThrows(BadInternationalizedPostalInfoException.class, () -> runFlow());
}
@Test
public void testFailure_declineDisclosure() throws Exception {
setEppInput("contact_create_decline_disclosure.xml");
thrown.expect(DeclineContactDisclosureFieldDisallowedPolicyException.class);
runFlow();
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, () -> runFlow());
}
@Test

View file

@ -23,6 +23,7 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableSet;
@ -71,17 +72,17 @@ public class ContactDeleteFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -116,8 +117,7 @@ public class ContactDeleteFlowTest
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -142,8 +142,7 @@ public class ContactDeleteFlowTest
createTld("tld");
persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
thrown.expect(ResourceToDeleteIsReferencedException.class);
runFlow();
assertThrows(ResourceToDeleteIsReferencedException.class, () -> runFlow());
}
@Test
@ -151,8 +150,7 @@ public class ContactDeleteFlowTest
createTld("tld");
persistResource(
newDomainResource("example.tld", persistActiveContact(getUniqueIdFromCommand())));
thrown.expect(ResourceToDeleteIsReferencedException.class);
runFlow();
assertThrows(ResourceToDeleteIsReferencedException.class, () -> runFlow());
}
@Test

View file

@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
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.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -163,17 +164,17 @@ public class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, C
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistContactResource(false);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test

View file

@ -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

View file

@ -22,6 +22,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;
@ -126,81 +128,86 @@ public class ContactTransferCancelFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("contact_transfer_cancel_with_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_cancel_with_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar");
thrown.expect(NotTransferInitiatorException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotTransferInitiatorException.class, () -> doFailingTest("contact_transfer_cancel.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(NotTransferInitiatorException.class);
doFailingTest("contact_transfer_cancel.xml");
assertThrows(
NotTransferInitiatorException.class, () -> doFailingTest("contact_transfer_cancel.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_cancel.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_cancel.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test

View file

@ -14,10 +14,13 @@
package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import google.registry.flows.ResourceFlowUtils.BadAuthInfoForResourceException;
import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
@ -138,8 +141,9 @@ public class ContactTransferQueryFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("contact_transfer_query_with_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_query_with_authinfo.xml"));
}
@Test
@ -147,39 +151,43 @@ public class ContactTransferQueryFlowTest
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
// code above will write the wrong ROID into the file.
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("contact_transfer_query_with_roid.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_query_with_roid.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NoTransferHistoryToQueryException.class);
doFailingTest("contact_transfer_query.xml");
assertThrows(
NoTransferHistoryToQueryException.class, () -> doFailingTest("contact_transfer_query.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(NotAuthorizedToViewTransferException.class);
doFailingTest("contact_transfer_query.xml");
assertThrows(
NotAuthorizedToViewTransferException.class,
() -> doFailingTest("contact_transfer_query.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_query.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_query.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("contact_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test

View file

@ -22,6 +22,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;
@ -141,81 +143,86 @@ public class ContactTransferRejectFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("contact_transfer_reject_with_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("contact_transfer_reject_with_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_gainingClient() throws Exception {
setClientIdForFlow("NewRegistrar");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("contact_transfer_reject.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("contact_transfer_reject.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_reject.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_reject.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test

View file

@ -28,6 +28,8 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@ -154,8 +156,9 @@ public class ContactTransferRequestFlowTest
@Test
public void testFailure_noAuthInfo() throws Exception {
thrown.expect(MissingTransferRequestAuthInfoException.class);
doFailingTest("contact_transfer_request_no_authinfo.xml");
assertThrows(
MissingTransferRequestAuthInfoException.class,
() -> doFailingTest("contact_transfer_request_no_authinfo.xml"));
}
@Test
@ -165,8 +168,8 @@ public class ContactTransferRequestFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("contact_transfer_request.xml");
assertThrows(
BadAuthInfoForResourceException.class, () -> doFailingTest("contact_transfer_request.xml"));
}
@Test
@ -208,59 +211,69 @@ public class ContactTransferRequestFlowTest
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
.build())
.build());
thrown.expect(AlreadyPendingTransferException.class);
doFailingTest("contact_transfer_request.xml");
assertThrows(
AlreadyPendingTransferException.class, () -> doFailingTest("contact_transfer_request.xml"));
}
@Test
public void testFailure_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar");
thrown.expect(ObjectAlreadySponsoredException.class);
doFailingTest("contact_transfer_request.xml");
assertThrows(
ObjectAlreadySponsoredException.class, () -> doFailingTest("contact_transfer_request.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_request.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentContact() throws Exception {
deleteResource(contact);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("contact_transfer_request.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_clientTransferProhibited() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("contact_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
}
@Test
public void testFailure_serverTransferProhibited() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("contact_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
}
@Test
public void testFailure_pendingDelete() throws Exception {
contact = persistResource(
contact.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("contact_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("contact_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test

View file

@ -14,12 +14,15 @@
package google.registry.flows.contact;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.ContactResourceSubject.assertAboutContacts;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.newContactResource;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@ -253,25 +256,24 @@ public class ContactUpdateFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_statusValueNotClientSettable() throws Exception {
setEppInput("contact_update_prohibited_status.xml");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(StatusNotClientSettableException.class);
runFlow();
assertThrows(StatusNotClientSettableException.class, () -> runFlow());
}
@Test
@ -289,8 +291,7 @@ public class ContactUpdateFlowTest
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -337,8 +338,7 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceHasClientUpdateProhibitedException.class);
runFlow();
assertThrows(ResourceHasClientUpdateProhibitedException.class, () -> runFlow());
}
@Test
@ -347,9 +347,9 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
}
@Test
@ -358,9 +358,9 @@ public class ContactUpdateFlowTest
newContactResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test
@ -373,24 +373,21 @@ public class ContactUpdateFlowTest
public void testFailure_nonAsciiInIntAddress() throws Exception {
setEppInput("contact_update_hebrew_int.xml");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(BadInternationalizedPostalInfoException.class);
runFlow();
assertThrows(BadInternationalizedPostalInfoException.class, () -> runFlow());
}
@Test
public void testFailure_declineDisclosure() throws Exception {
setEppInput("contact_update_decline_disclosure.xml");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(DeclineContactDisclosureFieldDisallowedPolicyException.class);
runFlow();
assertThrows(DeclineContactDisclosureFieldDisallowedPolicyException.class, () -> runFlow());
}
@Test
public void testFailure_addRemoveSameValue() throws Exception {
setEppInput("contact_update_add_remove_same.xml");
persistActiveContact(getUniqueIdFromCommand());
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test

View file

@ -30,6 +30,8 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
@ -253,9 +255,9 @@ public class DomainAllocateFlowTest
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlowAsSuperuser());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -268,9 +270,9 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net"))
.build());
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlowAsSuperuser();
RegistrantNotAllowedException thrown =
expectThrows(RegistrantNotAllowedException.class, () -> runFlowAsSuperuser());
assertThat(thrown).hasMessageThat().contains("jd1234");
}
@Test
@ -283,8 +285,9 @@ public class DomainAllocateFlowTest
.setAllowedRegistrantContactIds(ImmutableSet.of("jd1234"))
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.net, ns2.example.net"))
.build());
thrown.expect(NameserversNotSpecifiedForTldWithNameserverWhitelistException.class);
runFlowAsSuperuser();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class,
() -> runFlowAsSuperuser());
}
@Test
@ -313,9 +316,9 @@ public class DomainAllocateFlowTest
"reserved",
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlowAsSuperuser());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -330,8 +333,9 @@ public class DomainAllocateFlowTest
"reserved",
"example-one,NAMESERVER_RESTRICTED," + "ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotSpecifiedForNameserverRestrictedDomainException.class);
runFlowAsSuperuser();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class,
() -> runFlowAsSuperuser());
}
@Test
@ -366,9 +370,9 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns1.example.net", "ns2.example.net", "ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlowAsSuperuser());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -385,9 +389,9 @@ public class DomainAllocateFlowTest
.setAllowedFullyQualifiedHostNames(
ImmutableSet.of("ns4.example.net", "ns2.example.net", "ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlowAsSuperuser();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlowAsSuperuser());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -571,8 +575,7 @@ public class DomainAllocateFlowTest
public void testFailure_alreadyExists() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(ResourceAlreadyExistsException.class);
runFlowAsSuperuser();
assertThrows(ResourceAlreadyExistsException.class, () -> runFlowAsSuperuser());
}
@Test
@ -607,8 +610,7 @@ public class DomainAllocateFlowTest
public void testFailure_applicationDeleted() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
persistResource(application.asBuilder().setDeletionTime(clock.nowUtc()).build());
thrown.expect(MissingApplicationException.class);
runFlowAsSuperuser();
assertThrows(MissingApplicationException.class, () -> runFlowAsSuperuser());
}
@Test
@ -617,8 +619,7 @@ public class DomainAllocateFlowTest
persistResource(application.asBuilder()
.setApplicationStatus(ApplicationStatus.REJECTED)
.build());
thrown.expect(HasFinalStatusException.class);
runFlowAsSuperuser();
assertThrows(HasFinalStatusException.class, () -> runFlowAsSuperuser());
}
@Test
@ -627,16 +628,14 @@ public class DomainAllocateFlowTest
persistResource(application.asBuilder()
.setApplicationStatus(ApplicationStatus.ALLOCATED)
.build());
thrown.expect(HasFinalStatusException.class);
runFlowAsSuperuser();
assertThrows(HasFinalStatusException.class, () -> runFlowAsSuperuser());
}
@Test
public void testFailure_applicationDoesNotExist() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
setEppInput("domain_allocate_bad_application_roid.xml");
thrown.expect(MissingApplicationException.class);
runFlowAsSuperuser();
assertThrows(MissingApplicationException.class, () -> runFlowAsSuperuser());
}
@Test
@ -645,16 +644,16 @@ public class DomainAllocateFlowTest
clock.advanceOneMilli();
setEppInput("domain_allocate_no_nameservers.xml");
assertTransactionalFlow(true);
thrown.expect(OnlySuperuserCanAllocateException.class);
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
assertThrows(
OnlySuperuserCanAllocateException.class,
() -> runFlow(CommitMode.LIVE, UserPrivileges.NORMAL));
}
@Test
public void testFailure_max10Years() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
setEppInput("domain_allocate_11_years.xml");
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlowAsSuperuser();
assertThrows(ExceedsMaxRegistrationYearsException.class, () -> runFlowAsSuperuser());
}
@Test

View file

@ -34,6 +34,7 @@ import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Comparator.comparing;
import static org.joda.money.CurrencyUnit.EUR;
@ -245,8 +246,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_encoded_signed_mark_corrupt.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkParsingErrorException.class);
runFlow();
assertThrows(SignedMarkParsingErrorException.class, () -> runFlow());
}
@Test
@ -255,8 +255,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_encoded_signed_mark_revoked_cert.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkCertificateRevokedException.class);
runFlow();
assertThrows(SignedMarkCertificateRevokedException.class, () -> runFlow());
}
@Test
@ -267,8 +266,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
clock.setTo(DateTime.parse("2022-01-01"));
clock.setTo(DateTime.parse("2022-01-01"));
thrown.expect(SignedMarkCertificateExpiredException.class);
runFlow();
assertThrows(SignedMarkCertificateExpiredException.class, () -> runFlow());
}
@Test
@ -278,8 +276,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
clock.setTo(DateTime.parse("2012-07-22T00:01:00Z"));
thrown.expect(SignedMarkCertificateNotYetValidException.class);
runFlow();
assertThrows(SignedMarkCertificateNotYetValidException.class, () -> runFlow());
}
@Test
@ -296,8 +293,7 @@ public class DomainApplicationCreateFlowTest
public void verify(byte[] smdXml) throws GeneralSecurityException {
throw new GeneralSecurityException();
}};
thrown.expect(SignedMarkCertificateInvalidException.class);
runFlow();
assertThrows(SignedMarkCertificateInvalidException.class, () -> runFlow());
}
@Test
@ -307,8 +303,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_encoded_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkCertificateSignatureException.class);
runFlow();
assertThrows(SignedMarkCertificateSignatureException.class, () -> runFlow());
}
@Test
@ -317,8 +312,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_encoded_signed_mark_signature_corrupt.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkSignatureException.class);
runFlow();
assertThrows(SignedMarkSignatureException.class, () -> runFlow());
}
@Test
@ -394,8 +388,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_allowedinsunrise.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(DomainReservedException.class);
runFlow();
assertThrows(DomainReservedException.class, () -> runFlow());
}
@Test
@ -406,8 +399,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
// Modify the Registrar to block premium names.
persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build());
thrown.expect(PremiumNameBlockedException.class);
runFlow();
assertThrows(PremiumNameBlockedException.class, () -> runFlow());
}
@Test
@ -416,8 +408,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_premium.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
assertThrows(FeesRequiredForPremiumNameException.class, () -> runFlow());
}
@Test
@ -526,8 +517,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -537,8 +527,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
setEppInput(
"domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -548,8 +537,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
setEppInput(
"domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -559,8 +547,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -570,8 +557,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -581,8 +567,7 @@ public class DomainApplicationCreateFlowTest
clock.advanceOneMilli();
setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -591,8 +576,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -601,8 +585,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -611,8 +594,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -718,8 +700,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_without_marks.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(LandrushApplicationDisallowedDuringSunriseException.class);
runFlow();
assertThrows(LandrushApplicationDisallowedDuringSunriseException.class, () -> runFlow());
}
@Test
@ -734,8 +715,7 @@ public class DomainApplicationCreateFlowTest
.setState(State.SUSPENDED)
.build());
clock.advanceOneMilli();
thrown.expect(RegistrarMustBeActiveToCreateDomainsException.class);
runFlow();
assertThrows(RegistrarMustBeActiveToCreateDomainsException.class, () -> runFlow());
}
@Test
@ -744,8 +724,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SunriseApplicationDisallowedDuringLandrushException.class);
runFlow();
assertThrows(SunriseApplicationDisallowedDuringLandrushException.class, () -> runFlow());
}
@Test
@ -753,8 +732,7 @@ public class DomainApplicationCreateFlowTest
SignedMarkRevocationList.create(clock.nowUtc(), ImmutableMap.of(SMD_ID, clock.nowUtc())).save();
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkRevokedErrorException.class);
runFlow();
assertThrows(SignedMarkRevokedErrorException.class, () -> runFlow());
}
@Test
@ -763,8 +741,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_14_nameservers.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(TooManyNameserversException.class);
runFlow();
assertThrows(TooManyNameserversException.class, () -> runFlow());
}
@Test
@ -772,8 +749,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_with_secdns_maxsiglife.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(MaxSigLifeNotSupportedException.class);
runFlow();
assertThrows(MaxSigLifeNotSupportedException.class, () -> runFlow());
}
@Test
@ -781,8 +757,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_signed_mark_with_secdns_9_records.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(TooManyDsRecordsException.class);
runFlow();
assertThrows(TooManyDsRecordsException.class, () -> runFlow());
}
@Test
@ -790,8 +765,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_wrong_extension.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
@ -799,8 +773,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_signed_mark_reserved.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(DomainReservedException.class);
runFlow();
assertThrows(DomainReservedException.class, () -> runFlow());
}
@Test
@ -852,8 +825,7 @@ public class DomainApplicationCreateFlowTest
persistSunriseApplication();
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(UncontestedSunriseApplicationBlockedInLandrushException.class);
runFlow();
assertThrows(UncontestedSunriseApplicationBlockedInLandrushException.class, () -> runFlow());
}
@Test
@ -940,8 +912,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidLrpTokenException.class);
runFlow();
assertThrows(InvalidLrpTokenException.class, () -> runFlow());
}
@Test
@ -961,8 +932,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidLrpTokenException.class);
runFlow();
assertThrows(InvalidLrpTokenException.class, () -> runFlow());
}
@Test
@ -981,8 +951,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_lrp.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidLrpTokenException.class);
runFlow();
assertThrows(InvalidLrpTokenException.class, () -> runFlow());
}
@Test
@ -1037,8 +1006,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidLrpTokenException.class);
runFlow();
assertThrows(InvalidLrpTokenException.class, () -> runFlow());
}
@Test
@ -1047,8 +1015,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_months.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
@ -1056,9 +1023,9 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.net)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns2.example.net)");
}
@Test
@ -1066,9 +1033,9 @@ public class DomainApplicationCreateFlowTest
persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net");
persistActiveContact("jd1234");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(sh8013)");
}
@Test
@ -1077,8 +1044,7 @@ public class DomainApplicationCreateFlowTest
createTld("foo", TldState.SUNRISE);
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(TldDoesNotExistException.class);
runFlow();
assertThrows(TldDoesNotExistException.class, () -> runFlow());
}
@Test
@ -1086,8 +1052,7 @@ public class DomainApplicationCreateFlowTest
createTld("tld", TldState.PREDELEGATION);
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -1095,8 +1060,7 @@ public class DomainApplicationCreateFlowTest
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistContactsAndHosts();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -1104,8 +1068,7 @@ public class DomainApplicationCreateFlowTest
createTld("tld", TldState.SUNRUSH);
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(LaunchPhaseMismatchException.class);
runFlow();
assertThrows(LaunchPhaseMismatchException.class, () -> runFlow());
}
@Test
@ -1113,8 +1076,7 @@ public class DomainApplicationCreateFlowTest
createTld("tld", TldState.QUIET_PERIOD);
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -1122,8 +1084,7 @@ public class DomainApplicationCreateFlowTest
createTld("tld", TldState.GENERAL_AVAILABILITY);
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -1131,8 +1092,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(LaunchPhaseMismatchException.class);
runFlow();
assertThrows(LaunchPhaseMismatchException.class, () -> runFlow());
}
@Test
@ -1189,8 +1149,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_duplicate_contact.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -1199,8 +1158,7 @@ public class DomainApplicationCreateFlowTest
persistContactsAndHosts();
clock.advanceOneMilli();
// We need to test for missing type, but not for invalid - the schema enforces that for us.
thrown.expect(MissingContactTypeException.class);
runFlow();
assertThrows(MissingContactTypeException.class, () -> runFlow());
}
@Test
@ -1208,8 +1166,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_no_matching_marks.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow();
assertThrows(NoMarksFoundMatchingDomainException.class, () -> runFlow());
}
@Test
@ -1218,8 +1175,7 @@ public class DomainApplicationCreateFlowTest
clock.setTo(DateTime.parse("2013-08-09T10:05:59Z").minusSeconds(1));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow();
assertThrows(NoMarksFoundMatchingDomainException.class, () -> runFlow());
}
@Test
@ -1228,8 +1184,7 @@ public class DomainApplicationCreateFlowTest
clock.setTo(DateTime.parse("2017-07-23T22:00:00.000Z"));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow();
assertThrows(NoMarksFoundMatchingDomainException.class, () -> runFlow());
}
@Test
@ -1237,8 +1192,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_hex_encoding.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(Base64RequiredForEncodedSignedMarksException.class);
runFlow();
assertThrows(Base64RequiredForEncodedSignedMarksException.class, () -> runFlow());
}
@Test
@ -1246,8 +1200,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_bad_encoding.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkEncodingErrorException.class);
runFlow();
assertThrows(SignedMarkEncodingErrorException.class, () -> runFlow());
}
@Test
@ -1255,8 +1208,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_bad_encoded_xml.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkParsingErrorException.class);
runFlow();
assertThrows(SignedMarkParsingErrorException.class, () -> runFlow());
}
@Test
@ -1265,8 +1217,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_bad_idn_minna.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidIdnDomainLabelException.class);
runFlow();
assertThrows(InvalidIdnDomainLabelException.class, () -> runFlow());
}
@Test
@ -1276,8 +1227,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidTrademarkValidatorException.class);
runFlow();
assertThrows(InvalidTrademarkValidatorException.class, () -> runFlow());
}
@Test
@ -1285,8 +1235,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarksMustBeEncodedException.class);
runFlow();
assertThrows(SignedMarksMustBeEncodedException.class, () -> runFlow());
}
@Test
@ -1294,8 +1243,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_code_with_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(UnsupportedMarkTypeException.class);
runFlow();
assertThrows(UnsupportedMarkTypeException.class, () -> runFlow());
}
@Test
@ -1303,8 +1251,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_empty_encoded_signed_mark.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(SignedMarkParsingErrorException.class);
runFlow();
assertThrows(SignedMarkParsingErrorException.class, () -> runFlow());
}
@Test
@ -1313,8 +1260,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NoticeCannotBeUsedWithSignedMarkException.class);
runFlow();
assertThrows(NoticeCannotBeUsedWithSignedMarkException.class, () -> runFlow());
}
@Test
@ -1322,8 +1268,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrise_two_signed_marks.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(TooManySignedMarksException.class);
runFlow();
assertThrows(TooManySignedMarksException.class, () -> runFlow());
}
@Test
@ -1333,8 +1278,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(MissingClaimsNoticeException.class);
runFlow();
assertThrows(MissingClaimsNoticeException.class, () -> runFlow());
}
@Test
@ -1343,8 +1287,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_claim_notice.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(UnexpectedClaimsNoticeException.class);
runFlow();
assertThrows(UnexpectedClaimsNoticeException.class, () -> runFlow());
}
@Test
@ -1356,8 +1299,7 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder()
.setClaimsPeriodEnd(clock.nowUtc())
.build());
thrown.expect(ClaimsPeriodEndedException.class);
runFlow();
assertThrows(ClaimsPeriodEndedException.class, () -> runFlow());
}
@Test
@ -1368,8 +1310,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(ExpiredClaimException.class);
runFlow();
assertThrows(ExpiredClaimException.class, () -> runFlow());
}
@Test
@ -1380,8 +1321,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(AcceptedTooLongAgoException.class);
runFlow();
assertThrows(AcceptedTooLongAgoException.class, () -> runFlow());
}
@Test
@ -1392,8 +1332,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_malformed_claim_notice1.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(MalformedTcnIdException.class);
runFlow();
assertThrows(MalformedTcnIdException.class, () -> runFlow());
}
@Test
@ -1404,8 +1343,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_sunrush_malformed_claim_notice2.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(MalformedTcnIdException.class);
runFlow();
assertThrows(MalformedTcnIdException.class, () -> runFlow());
}
@Test
@ -1416,8 +1354,7 @@ public class DomainApplicationCreateFlowTest
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(InvalidTcnIdChecksumException.class);
runFlow();
assertThrows(InvalidTcnIdChecksumException.class, () -> runFlow());
}
@Test
@ -1428,8 +1365,7 @@ public class DomainApplicationCreateFlowTest
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -1440,8 +1376,7 @@ public class DomainApplicationCreateFlowTest
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -1452,8 +1387,7 @@ public class DomainApplicationCreateFlowTest
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -1470,8 +1404,7 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -1488,8 +1421,7 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -1506,8 +1438,7 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -1516,8 +1447,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
@ -1526,8 +1456,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
@ -1536,8 +1465,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@ -1565,9 +1493,9 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build());
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow();
RegistrantNotAllowedException thrown =
expectThrows(RegistrantNotAllowedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("jd1234");
}
@Test
@ -1576,9 +1504,9 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1603,8 +1531,8 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotSpecifiedForTldWithNameserverWhitelistException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, () -> runFlow());
}
@Test
@ -1638,9 +1566,9 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1656,8 +1584,8 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotSpecifiedForNameserverRestrictedDomainException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, () -> runFlow());
}
@Test
@ -1697,9 +1625,9 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1717,9 +1645,9 @@ public class DomainApplicationCreateFlowTest
.build());
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1728,8 +1656,7 @@ public class DomainApplicationCreateFlowTest
setEppInput("domain_create_landrush_11_years.xml");
persistContactsAndHosts();
clock.advanceOneMilli();
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlow();
assertThrows(ExceedsMaxRegistrationYearsException.class, () -> runFlow());
}
private void doFailingDomainNameTest(String domainName, Class<? extends Throwable> exception)

View file

@ -26,6 +26,8 @@ import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -123,9 +125,9 @@ public class DomainApplicationDeleteFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -134,9 +136,9 @@ public class DomainApplicationDeleteFlowTest
.setRepoId("1-TLD")
.setDeletionTime(clock.nowUtc().minusSeconds(1))
.build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -144,8 +146,7 @@ public class DomainApplicationDeleteFlowTest
sessionMetadata.setClientId("NewRegistrar");
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -163,8 +164,7 @@ public class DomainApplicationDeleteFlowTest
persistResource(newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -186,8 +186,7 @@ public class DomainApplicationDeleteFlowTest
.setRepoId("1-TLD")
.setPhase(LaunchPhase.SUNRISE)
.build());
thrown.expect(SunriseApplicationCannotBeDeletedInLandrushException.class);
runFlow();
assertThrows(SunriseApplicationCannotBeDeletedInLandrushException.class, () -> runFlow());
}
@Test
@ -233,16 +232,14 @@ public class DomainApplicationDeleteFlowTest
setEppInput("domain_delete_application_landrush.xml", ImmutableMap.of("DOMAIN", "example.tld"));
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(LaunchPhaseMismatchException.class);
runFlow();
assertThrows(LaunchPhaseMismatchException.class, () -> runFlow());
}
@Test
public void testFailure_wrongExtension() throws Exception {
setEppInput("domain_delete_application_wrong_extension.xml");
persistActiveDomainApplication("example.tld");
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
@ -250,8 +247,7 @@ public class DomainApplicationDeleteFlowTest
createTld("tld", TldState.PREDELEGATION);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -259,8 +255,7 @@ public class DomainApplicationDeleteFlowTest
createTld("tld", TldState.QUIET_PERIOD);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -268,8 +263,7 @@ public class DomainApplicationDeleteFlowTest
createTld("tld", TldState.GENERAL_AVAILABILITY);
persistResource(
newDomainApplication("example.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -306,8 +300,7 @@ public class DomainApplicationDeleteFlowTest
public void testFailure_applicationIdForDifferentDomain() throws Exception {
persistResource(
newDomainApplication("invalid.tld").asBuilder().setRepoId("1-TLD").build());
thrown.expect(ApplicationDomainNameMismatchException.class);
runFlow();
assertThrows(ApplicationDomainNameMismatchException.class, () -> runFlow());
}
@Test

View file

@ -22,6 +22,8 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
@ -261,9 +263,9 @@ public class DomainApplicationInfoFlowTest
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -274,9 +276,9 @@ public class DomainApplicationInfoFlowTest
.setDeletionTime(clock.nowUtc().minusDays(1))
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -285,8 +287,7 @@ public class DomainApplicationInfoFlowTest
AppEngineRule.makeRegistrar1().asBuilder().setClientId("ClientZ").build());
sessionMetadata.setClientId("ClientZ");
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -297,16 +298,14 @@ public class DomainApplicationInfoFlowTest
.setRegistrant(Key.create(persistActiveContact("jd1234")))
.setPhase(LaunchPhase.SUNRUSH)
.build());
thrown.expect(ApplicationDomainNameMismatchException.class);
runFlow();
assertThrows(ApplicationDomainNameMismatchException.class, () -> runFlow());
}
@Test
public void testFailure_noApplicationId() throws Exception {
setEppInput("domain_info_sunrise_no_application_id.xml");
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
thrown.expect(MissingApplicationIdException.class);
runFlow();
assertThrows(MissingApplicationIdException.class, () -> runFlow());
}
@Test
@ -314,8 +313,7 @@ public class DomainApplicationInfoFlowTest
persistTestEntities(HostsState.NO_HOSTS_EXIST, MarksState.NO_MARKS_EXIST);
application = persistResource(
application.asBuilder().setPhase(LaunchPhase.SUNRISE).build());
thrown.expect(ApplicationLaunchPhaseMismatchException.class);
runFlow();
assertThrows(ApplicationLaunchPhaseMismatchException.class, () -> runFlow());
}
/** Test that we load contacts and hosts as a batch rather than individually. */

View file

@ -29,6 +29,7 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainApplicationSubject.assertAboutApplications;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableMap;
@ -371,8 +372,7 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_dsdata_add.xml");
persistResource(newApplicationBuilder().setDsData(builder.build()).build());
thrown.expect(TooManyDsRecordsException.class);
runFlow();
assertThrows(TooManyDsRecordsException.class, () -> runFlow());
}
private void modifyApplicationToHave13Nameservers() throws Exception {
@ -395,40 +395,37 @@ public class DomainApplicationUpdateFlowTest
// Modify application to have 13 nameservers. We will then remove one and add one in the test.
modifyApplicationToHave13Nameservers();
setEppInput("domain_update_sunrise_add_nameserver.xml");
thrown.expect(TooManyNameserversException.class);
runFlow();
assertThrows(TooManyNameserversException.class, () -> runFlow());
}
@Test
public void testFailure_wrongExtension() throws Exception {
setEppInput("domain_update_sunrise_wrong_extension.xml");
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
public void testFailure_applicationDomainNameMismatch() throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setFullyQualifiedDomainName("something.tld").build());
thrown.expect(ApplicationDomainNameMismatchException.class);
runFlow();
assertThrows(ApplicationDomainNameMismatchException.class, () -> runFlow());
}
@Test
public void testFailure_neverExisted() throws Exception {
persistReferencedEntities();
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setDeletionTime(START_OF_TIME).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -437,8 +434,7 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)).build());
thrown.expect(ResourceHasClientUpdateProhibitedException.class);
runFlow();
assertThrows(ResourceHasClientUpdateProhibitedException.class, () -> runFlow());
}
@Test
@ -446,16 +442,15 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistResource(newApplicationBuilder().setStatusValues(
ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED)).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
}
private void doIllegalApplicationStatusTest(ApplicationStatus status) throws Exception {
persistReferencedEntities();
persistResource(newApplicationBuilder().setApplicationStatus(status).build());
thrown.expect(ApplicationStatusProhibitsUpdateException.class);
runFlow();
assertThrows(ApplicationStatusProhibitsUpdateException.class, () -> runFlow());
}
@Test
@ -479,9 +474,9 @@ public class DomainApplicationUpdateFlowTest
persistActiveContact("sh8013");
persistActiveContact("mak21");
persistNewApplication();
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.tld)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns2.example.tld)");
}
@Test
@ -490,9 +485,9 @@ public class DomainApplicationUpdateFlowTest
persistActiveHost("ns2.example.tld");
persistActiveContact("mak21");
persistNewApplication();
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(sh8013)");
}
@Test
@ -505,8 +500,7 @@ public class DomainApplicationUpdateFlowTest
persistResource(reloadDomainApplication().asBuilder().setContacts(ImmutableSet.of(
DesignatedContact.create(Type.TECH, Key.create(
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()))))).build());
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -514,8 +508,7 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_prohibited_status.xml");
persistReferencedEntities();
persistNewApplication();
thrown.expect(StatusNotClientSettableException.class);
runFlow();
assertThrows(StatusNotClientSettableException.class, () -> runFlow());
}
@ -536,8 +529,7 @@ public class DomainApplicationUpdateFlowTest
setEppInput("domain_update_sunrise_duplicate_contact.xml");
persistReferencedEntities();
persistNewApplication();
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -546,8 +538,7 @@ public class DomainApplicationUpdateFlowTest
persistReferencedEntities();
persistNewApplication();
// We need to test for missing type, but not for invalid - the schema enforces that for us.
thrown.expect(MissingContactTypeException.class);
runFlow();
assertThrows(MissingContactTypeException.class, () -> runFlow());
}
@Test
@ -555,8 +546,7 @@ public class DomainApplicationUpdateFlowTest
sessionMetadata.setClientId("NewRegistrar");
persistReferencedEntities();
persistApplication();
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -575,8 +565,7 @@ public class DomainApplicationUpdateFlowTest
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistReferencedEntities();
persistApplication();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -598,8 +587,7 @@ public class DomainApplicationUpdateFlowTest
.setNameservers(ImmutableSet.of(Key.create(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
.build());
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -612,8 +600,7 @@ public class DomainApplicationUpdateFlowTest
Key.create(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -625,8 +612,7 @@ public class DomainApplicationUpdateFlowTest
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
thrown.expect(MissingAdminContactException.class);
runFlow();
assertThrows(MissingAdminContactException.class, () -> runFlow());
}
@Test
@ -638,8 +624,7 @@ public class DomainApplicationUpdateFlowTest
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
thrown.expect(MissingTechnicalContactException.class);
runFlow();
assertThrows(MissingTechnicalContactException.class, () -> runFlow());
}
@Test
@ -651,8 +636,7 @@ public class DomainApplicationUpdateFlowTest
.setAllowedRegistrantContactIds(ImmutableSet.of("contact1234"))
.build());
clock.advanceOneMilli();
thrown.expect(RegistrantNotAllowedException.class);
runFlow();
assertThrows(RegistrantNotAllowedException.class, () -> runFlow());
}
@Test
@ -664,8 +648,7 @@ public class DomainApplicationUpdateFlowTest
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class);
runFlow();
assertThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
}
@Test
@ -692,8 +675,8 @@ public class DomainApplicationUpdateFlowTest
ImmutableSet.of("ns1.example.tld", "ns2.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotSpecifiedForTldWithNameserverWhitelistException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, () -> runFlow());
}
@Test
@ -746,9 +729,9 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
}
@Test
@ -764,8 +747,8 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotSpecifiedForNameserverRestrictedDomainException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, () -> runFlow());
}
@Test
@ -825,9 +808,9 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns3.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
}
@Test
@ -845,9 +828,9 @@ public class DomainApplicationUpdateFlowTest
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.tld:ns2.example.tld"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
}
@Test
@ -859,8 +842,7 @@ public class DomainApplicationUpdateFlowTest
"domain_update_sunrise_fee.xml",
ImmutableMap.of("DOMAIN", "non-free-update.tld", "AMOUNT", "12.00"));
clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test

View file

@ -274,23 +274,20 @@ public class DomainCheckFlowTest
@Test
public void testFailure_tooManyIds() throws Exception {
setEppInput("domain_check_51.xml");
thrown.expect(TooManyResourceChecksException.class);
runFlow();
assertThrows(TooManyResourceChecksException.class, () -> runFlow());
}
@Test
public void testFailure_wrongTld() throws Exception {
setEppInput("domain_check.xml");
thrown.expect(TldDoesNotExistException.class);
runFlow();
assertThrows(TldDoesNotExistException.class, () -> runFlow());
}
@Test
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -389,8 +386,7 @@ public class DomainCheckFlowTest
@Test
public void testFailure_predelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION);
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -677,177 +673,152 @@ public class DomainCheckFlowTest
@Test
public void testFeeExtension_wrongCurrency_v06() throws Exception {
setEppInput("domain_check_fee_euro_v06.xml");
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
public void testFeeExtension_wrongCurrency_v11() throws Exception {
setEppInput("domain_check_fee_euro_v11.xml");
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
public void testFeeExtension_wrongCurrency_v12() throws Exception {
setEppInput("domain_check_fee_euro_v12.xml");
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
public void testFeeExtension_periodNotInYears_v06() throws Exception {
setEppInput("domain_check_fee_bad_period_v06.xml");
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
public void testFeeExtension_periodNotInYears_v11() throws Exception {
setEppInput("domain_check_fee_bad_period_v11.xml");
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
public void testFeeExtension_periodNotInYears_v12() throws Exception {
setEppInput("domain_check_fee_bad_period_v12.xml");
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandWithPhase_v06() throws Exception {
setEppInput("domain_check_fee_command_phase_v06.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandWithPhase_v11() throws Exception {
setEppInput("domain_check_fee_command_phase_v11.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandWithPhase_v12() throws Exception {
setEppInput("domain_check_fee_command_phase_v12.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandSubphase_v06() throws Exception {
setEppInput("domain_check_fee_command_subphase_v06.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandSubphase_v11() throws Exception {
setEppInput("domain_check_fee_command_subphase_v11.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
@Test
public void testFeeExtension_commandSubphase_v12() throws Exception {
setEppInput("domain_check_fee_command_subphase_v12.xml");
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
// This test is only relevant for v06, since domain names are not specified in v11 or v12.
@Test
public void testFeeExtension_feeCheckNotInAvailabilityCheck() throws Exception {
setEppInput("domain_check_fee_not_in_avail.xml");
thrown.expect(OnlyCheckedNamesCanBeFeeCheckedException.class);
runFlow();
assertThrows(OnlyCheckedNamesCanBeFeeCheckedException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearRestore_v06() throws Exception {
setEppInput("domain_check_fee_multiyear_restore_v06.xml");
thrown.expect(RestoresAreAlwaysForOneYearException.class);
runFlow();
assertThrows(RestoresAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearRestore_v11() throws Exception {
setEppInput("domain_check_fee_multiyear_restore_v11.xml");
thrown.expect(RestoresAreAlwaysForOneYearException.class);
runFlow();
assertThrows(RestoresAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearRestore_v12() throws Exception {
setEppInput("domain_check_fee_multiyear_restore_v12.xml");
thrown.expect(RestoresAreAlwaysForOneYearException.class);
runFlow();
assertThrows(RestoresAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearTransfer_v06() throws Exception {
setEppInput("domain_check_fee_multiyear_transfer_v06.xml");
thrown.expect(TransfersAreAlwaysForOneYearException.class);
runFlow();
assertThrows(TransfersAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearTransfer_v11() throws Exception {
setEppInput("domain_check_fee_multiyear_transfer_v11.xml");
thrown.expect(TransfersAreAlwaysForOneYearException.class);
runFlow();
assertThrows(TransfersAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_multiyearTransfer_v12() throws Exception {
setEppInput("domain_check_fee_multiyear_transfer_v12.xml");
thrown.expect(TransfersAreAlwaysForOneYearException.class);
runFlow();
assertThrows(TransfersAreAlwaysForOneYearException.class, () -> runFlow());
}
@Test
public void testFeeExtension_unknownCommand_v06() throws Exception {
setEppInput("domain_check_fee_unknown_command_v06.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
@Test
public void testFeeExtension_unknownCommand_v11() throws Exception {
setEppInput("domain_check_fee_unknown_command_v11.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
@Test
public void testFeeExtension_unknownCommand_v12() throws Exception {
setEppInput("domain_check_fee_unknown_command_v12.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
@Test
public void testFeeExtension_invalidCommand_v06() throws Exception {
setEppInput("domain_check_fee_invalid_command_v06.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
@Test
public void testFeeExtension_invalidCommand_v11() throws Exception {
setEppInput("domain_check_fee_invalid_command_v11.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
@Test
public void testFeeExtension_invalidCommand_v12() throws Exception {
setEppInput("domain_check_fee_invalid_command_v12.xml");
thrown.expect(UnknownFeeCommandException.class);
runFlow();
assertThrows(UnknownFeeCommandException.class, () -> runFlow());
}
private void runEapFeeCheckTest(String inputFile, String outputFile) throws Exception {

View file

@ -18,6 +18,7 @@ import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -101,23 +102,20 @@ public class DomainClaimsCheckFlowTest
@Test
public void testFailure_TooManyIds() throws Exception {
setEppInput("domain_check_claims_51.xml");
thrown.expect(TooManyResourceChecksException.class);
runFlow();
assertThrows(TooManyResourceChecksException.class, () -> runFlow());
}
@Test
public void testFailure_tldDoesntExist() throws Exception {
setEppInput("domain_check_claims_bad_tld.xml");
thrown.expect(TldDoesNotExistException.class);
runFlow();
assertThrows(TldDoesNotExistException.class, () -> runFlow());
}
@Test
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -138,8 +136,7 @@ public class DomainClaimsCheckFlowTest
createTld("tld", TldState.PREDELEGATION);
persistResource(Registry.get("tld").asBuilder().build());
setEppInput("domain_check_claims.xml");
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -147,8 +144,7 @@ public class DomainClaimsCheckFlowTest
createTld("tld", TldState.SUNRISE);
persistResource(Registry.get("tld").asBuilder().build());
setEppInput("domain_check_claims.xml");
thrown.expect(DomainClaimsCheckNotAllowedInSunrise.class);
runFlow();
assertThrows(DomainClaimsCheckNotAllowedInSunrise.class, () -> runFlow());
}
@Test
@ -158,8 +154,7 @@ public class DomainClaimsCheckFlowTest
persistResource(
Registry.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build());
setEppInput("domain_check_claims_multiple_tlds.xml");
thrown.expect(ClaimsPeriodEndedException.class);
runFlow();
assertThrows(ClaimsPeriodEndedException.class, () -> runFlow());
}
@Test

View file

@ -386,8 +386,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTlds("foo.tld", "tld");
setEppInput("domain_create_wildcard.xml", ImmutableMap.of("DOMAIN", "foo.tld"));
persistContactsAndHosts();
thrown.expect(DomainNameExistsAsTldException.class);
runFlow();
assertThrows(DomainNameExistsAsTldException.class, () -> runFlow());
}
@Test
@ -395,8 +394,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTlds("foo.tld", "tld");
setEppInput("domain_create_wildcard.xml", ImmutableMap.of("DOMAIN", "FOO.TLD"));
persistContactsAndHosts();
thrown.expect(BadDomainNameCharacterException.class);
runFlow();
assertThrows(BadDomainNameCharacterException.class, () -> runFlow());
}
@Test
@ -536,72 +534,63 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_refundableFee_v06() throws Exception {
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v11() throws Exception {
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v12() throws Exception {
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v06() throws Exception {
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v11() throws Exception {
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v12() throws Exception {
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v06() throws Exception {
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v11() throws Exception {
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v12() throws Exception {
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -621,8 +610,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_metadataNotFromTool() throws Exception {
setEppInput("domain_create_metadata.xml");
persistContactsAndHosts();
thrown.expect(OnlyToolCanPassMetadataException.class);
runFlow();
assertThrows(OnlyToolCanPassMetadataException.class, () -> runFlow());
}
@Test
@ -649,9 +637,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setLrpPeriod(new Interval(clock.nowUtc().minusDays(1), clock.nowUtc().plusDays(1)))
.build());
persistContactsAndHosts();
thrown.expect(InvalidLrpTokenException.class);
thrown.expectMessage("Invalid limited registration period token");
runFlow();
InvalidLrpTokenException thrown = expectThrows(InvalidLrpTokenException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("Invalid limited registration period token");
}
@Test
@ -750,8 +737,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_periodInMonths() throws Exception {
setEppInput("domain_create_months.xml");
persistContactsAndHosts();
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
@ -783,8 +769,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistClaimsList(ImmutableMap.of("example", CLAIMS_KEY));
setEppInput("domain_create.xml");
persistContactsAndHosts();
thrown.expect(MissingClaimsNoticeException.class);
runFlow();
assertThrows(MissingClaimsNoticeException.class, () -> runFlow());
}
@Test
@ -792,8 +777,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_claim_notice.xml");
persistClaimsList(ImmutableMap.of());
persistContactsAndHosts();
thrown.expect(UnexpectedClaimsNoticeException.class);
runFlow();
assertThrows(UnexpectedClaimsNoticeException.class, () -> runFlow());
}
@Test
@ -804,40 +788,35 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setClaimsPeriodEnd(clock.nowUtc())
.build());
thrown.expect(ClaimsPeriodEndedException.class);
runFlow();
assertThrows(ClaimsPeriodEndedException.class, () -> runFlow());
}
@Test
public void testFailure_tooManyNameservers() throws Exception {
setEppInput("domain_create_14_nameservers.xml");
persistContactsAndHosts();
thrown.expect(TooManyNameserversException.class);
runFlow();
assertThrows(TooManyNameserversException.class, () -> runFlow());
}
@Test
public void testFailure_secDnsMaxSigLife() throws Exception {
setEppInput("domain_create_dsdata.xml");
persistContactsAndHosts();
thrown.expect(MaxSigLifeNotSupportedException.class);
runFlow();
assertThrows(MaxSigLifeNotSupportedException.class, () -> runFlow());
}
@Test
public void testFailure_secDnsTooManyDsRecords() throws Exception {
setEppInput("domain_create_dsdata_9_records.xml");
persistContactsAndHosts();
thrown.expect(TooManyDsRecordsException.class);
runFlow();
assertThrows(TooManyDsRecordsException.class, () -> runFlow());
}
@Test
public void testFailure_wrongExtension() throws Exception {
setEppInput("domain_create_wrong_extension.xml");
persistContactsAndHosts();
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
@ -846,8 +825,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -856,8 +834,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -866,8 +843,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -882,8 +858,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistContactsAndHosts();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -898,8 +873,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistContactsAndHosts();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -914,8 +888,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistContactsAndHosts();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -939,16 +912,14 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_reserved() throws Exception {
setEppInput("domain_create_reserved.xml");
persistContactsAndHosts();
thrown.expect(DomainReservedException.class);
runFlow();
assertThrows(DomainReservedException.class, () -> runFlow());
}
@Test
public void testFailure_anchorTenantViaAuthCode_wrongAuthCode() throws Exception {
setEppInput("domain_create_anchor_wrong_authcode.xml");
persistContactsAndHosts();
thrown.expect(DomainReservedException.class);
runFlow();
assertThrows(DomainReservedException.class, () -> runFlow());
}
@Test
@ -1045,9 +1016,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.net)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns2.example.net)");
}
@Test
@ -1059,9 +1030,10 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("ns2.example.net");
runFlow();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
expectThrows(
LinkedResourceInPendingDeleteProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.net");
}
@Test
@ -1069,8 +1041,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistContactsAndHosts();
persistActiveDomainApplication(getUniqueIdFromCommand());
clock.advanceOneMilli();
thrown.expect(DomainHasOpenApplicationsException.class);
runFlow();
assertThrows(DomainHasOpenApplicationsException.class, () -> runFlow());
}
@Test
@ -1095,9 +1066,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net");
persistActiveContact("jd1234");
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(sh8013)");
}
@Test
@ -1109,57 +1080,52 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("jd1234");
runFlow();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
expectThrows(
LinkedResourceInPendingDeleteProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("jd1234");
}
@Test
public void testFailure_wrongTld() throws Exception {
persistContactsAndHosts("net");
deleteTld("tld");
thrown.expect(TldDoesNotExistException.class);
runFlow();
assertThrows(TldDoesNotExistException.class, () -> runFlow());
}
@Test
public void testFailure_predelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION);
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
public void testFailure_sunrise() throws Exception {
createTld("tld", TldState.SUNRISE);
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
public void testFailure_sunrush() throws Exception {
createTld("tld", TldState.SUNRUSH);
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
public void testFailure_landrush() throws Exception {
createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
public void testFailure_quietPeriod() throws Exception {
createTld("tld", TldState.QUIET_PERIOD);
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
@ -1232,8 +1198,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_duplicateContact() throws Exception {
setEppInput("domain_create_duplicate_contact.xml");
persistContactsAndHosts();
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -1241,40 +1206,35 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
// We need to test for missing type, but not for invalid - the schema enforces that for us.
setEppInput("domain_create_missing_contact_type.xml");
persistContactsAndHosts();
thrown.expect(MissingContactTypeException.class);
runFlow();
assertThrows(MissingContactTypeException.class, () -> runFlow());
}
@Test
public void testFailure_missingRegistrant() throws Exception {
setEppInput("domain_create_missing_registrant.xml");
persistContactsAndHosts();
thrown.expect(MissingRegistrantException.class);
runFlow();
assertThrows(MissingRegistrantException.class, () -> runFlow());
}
@Test
public void testFailure_missingAdmin() throws Exception {
setEppInput("domain_create_missing_admin.xml");
persistContactsAndHosts();
thrown.expect(MissingAdminContactException.class);
runFlow();
assertThrows(MissingAdminContactException.class, () -> runFlow());
}
@Test
public void testFailure_missingTech() throws Exception {
setEppInput("domain_create_missing_tech.xml");
persistContactsAndHosts();
thrown.expect(MissingTechnicalContactException.class);
runFlow();
assertThrows(MissingTechnicalContactException.class, () -> runFlow());
}
@Test
public void testFailure_missingNonRegistrantContacts() throws Exception {
setEppInput("domain_create_missing_non_registrant_contacts.xml");
persistContactsAndHosts();
thrown.expect(MissingAdminContactException.class);
runFlow();
assertThrows(MissingAdminContactException.class, () -> runFlow());
}
@Test
@ -1282,8 +1242,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("xn--q9jyb4c");
setEppInput("domain_create_bad_idn_minna.xml");
persistContactsAndHosts("net");
thrown.expect(InvalidIdnDomainLabelException.class);
runFlow();
assertThrows(InvalidIdnDomainLabelException.class, () -> runFlow());
}
@Test
@ -1291,16 +1250,14 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
setEppInput("domain_create_bad_validator_id.xml");
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts();
thrown.expect(InvalidTrademarkValidatorException.class);
runFlow();
assertThrows(InvalidTrademarkValidatorException.class, () -> runFlow());
}
@Test
public void testFailure_codeMark() throws Exception {
setEppInput("domain_create_code_with_mark.xml");
persistContactsAndHosts();
thrown.expect(UnsupportedMarkTypeException.class);
runFlow();
assertThrows(UnsupportedMarkTypeException.class, () -> runFlow());
}
@Test
@ -1308,8 +1265,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("tld", TldState.SUNRISE);
setEppInput("domain_create_signed_mark.xml");
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
@ -1317,8 +1273,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistContactsAndHosts();
thrown.expect(ExpiredClaimException.class);
runFlow();
assertThrows(ExpiredClaimException.class, () -> runFlow());
}
@Test
@ -1326,8 +1281,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml");
persistContactsAndHosts();
thrown.expect(AcceptedTooLongAgoException.class);
runFlow();
assertThrows(AcceptedTooLongAgoException.class, () -> runFlow());
}
@Test
@ -1335,8 +1289,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice1.xml");
persistContactsAndHosts();
thrown.expect(MalformedTcnIdException.class);
runFlow();
assertThrows(MalformedTcnIdException.class, () -> runFlow());
}
@Test
@ -1344,8 +1297,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice2.xml");
persistContactsAndHosts();
thrown.expect(MalformedTcnIdException.class);
runFlow();
assertThrows(MalformedTcnIdException.class, () -> runFlow());
}
@Test
@ -1353,8 +1305,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_bad_checksum_claim_notice.xml");
persistContactsAndHosts();
thrown.expect(InvalidTcnIdChecksumException.class);
runFlow();
assertThrows(InvalidTcnIdChecksumException.class, () -> runFlow());
}
@Test
@ -1367,8 +1318,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(loadRegistrar("TheRegistrar").asBuilder()
.setBlockPremiumNames(true)
.build());
thrown.expect(PremiumNameBlockedException.class);
runFlow();
assertThrows(PremiumNameBlockedException.class, () -> runFlow());
}
@Test
@ -1376,8 +1326,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("example");
setEppInput("domain_create_premium.xml");
persistContactsAndHosts("net");
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
assertThrows(FeesRequiredForPremiumNameException.class, () -> runFlow());
}
@Test
@ -1388,8 +1337,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow();
assertThrows(UndeclaredServiceExtensionException.class, () -> runFlow());
}
@Test
@ -1400,8 +1348,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow();
assertThrows(UndeclaredServiceExtensionException.class, () -> runFlow());
}
@Test
@ -1412,32 +1359,28 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow();
assertThrows(UndeclaredServiceExtensionException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception {
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception {
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception {
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
@ -1450,8 +1393,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.asBuilder()
.setState(State.SUSPENDED)
.build());
thrown.expect(RegistrarMustBeActiveToCreateDomainsException.class);
runFlow();
assertThrows(RegistrarMustBeActiveToCreateDomainsException.class, () -> runFlow());
}
private void doFailingDomainNameTest(
@ -1534,8 +1476,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("tld", TldState.SUNRISE);
setEppInput("domain_create_registration_sunrise.xml");
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
@ -1586,8 +1527,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("tld", TldState.SUNRUSH);
setEppInput("domain_create_registration_sunrush.xml");
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
@ -1599,8 +1539,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setAllowedTlds(ImmutableSet.of("irrelevant"))
.build());
persistContactsAndHosts();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -1651,8 +1590,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_registration_landrush.xml");
persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow();
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, () -> runFlow());
}
@Test
@ -1705,9 +1643,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setAllowedRegistrantContactIds(ImmutableSet.of("someone"))
.build());
thrown.expect(RegistrantNotAllowedException.class);
thrown.expectMessage("jd1234");
runFlow();
RegistrantNotAllowedException thrown =
expectThrows(RegistrantNotAllowedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("jd1234");
}
@Test
@ -1716,9 +1654,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistResource(Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns2.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1728,8 +1666,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("somethingelse.example.net"))
.build());
persistContactsAndHosts();
thrown.expect(NameserversNotSpecifiedForTldWithNameserverWhitelistException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, () -> runFlow());
}
@Test
@ -1770,8 +1708,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotSpecifiedForNameserverRestrictedDomainException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, () -> runFlow());
}
@Test
@ -1784,9 +1722,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1800,9 +1738,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistReservedList(
"reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.net:ns2.example.net"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow();
DomainNotAllowedForTldWithCreateRestrictionException thrown =
expectThrows(DomainNotAllowedForTldWithCreateRestrictionException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("example.tld");
}
@Test
@ -1850,9 +1788,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1869,9 +1807,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"example,NAMESERVER_RESTRICTED,"
+ "ns2.example.net:ns3.example.net:ns4.example.net"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns1.example.net");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.net");
}
@Test
@ -1890,9 +1828,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
"lol,NAMESERVER_RESTRICTED,"
+ "ns1.example.net:ns2.example.net:ns3.example.net"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
thrown.expectMessage("example.tld");
runFlow();
DomainNotAllowedForTldWithCreateRestrictionException thrown =
expectThrows(DomainNotAllowedForTldWithCreateRestrictionException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("example.tld");
}
@Test
@ -2020,8 +1958,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
public void testFailure_max10Years() throws Exception {
setEppInput("domain_create_11_years.xml");
persistContactsAndHosts();
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlow();
assertThrows(ExceedsMaxRegistrationYearsException.class, () -> runFlow());
}
@Test

View file

@ -42,6 +42,8 @@ import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@ -636,8 +638,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
public void testFailure_predelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION);
setUpSuccessfulTest();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow();
assertThrows(BadCommandForRegistryPhaseException.class, () -> runFlow());
}
@Test
@ -651,17 +652,17 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -674,16 +675,14 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
domain = persistResource(domain.asBuilder()
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
.build());
thrown.expect(DomainToDeleteHasHostsException.class);
runFlow();
assertThrows(DomainToDeleteHasHostsException.class, () -> runFlow());
}
@Test
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -700,8 +699,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
setUpSuccessfulTest();
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -719,9 +717,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientDeleteProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("clientDeleteProhibited");
}
@Test
@ -729,9 +727,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverDeleteProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverDeleteProhibited");
}
@Test
@ -739,9 +737,9 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test
@ -764,8 +762,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
public void testFailure_metadataNotFromTool() throws Exception {
setEppInput("domain_delete_metadata.xml");
persistResource(newDomainResource(getUniqueIdFromCommand()));
thrown.expect(OnlyToolCanPassMetadataException.class);
runFlow();
assertThrows(OnlyToolCanPassMetadataException.class, () -> runFlow());
}
@Test

View file

@ -23,6 +23,8 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableMap;
@ -373,9 +375,9 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -383,9 +385,9 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
persistResource(newDomainResource("example.tld").asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -397,8 +399,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
.build());
sessionMetadata.setClientId("ClientZ");
setEppInput("domain_info_with_auth.xml");
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -409,8 +410,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("diffpw")))
.build());
setEppInput("domain_info_with_auth.xml");
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -425,8 +425,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our registrant.
eppLoader.replaceAll("JD1234-REP", registrant.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -440,8 +439,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our registrant.
eppLoader.replaceAll("JD1234-REP", registrant.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -456,8 +454,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our contact.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -471,8 +468,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our contact.
eppLoader.replaceAll("JD1234-REP", contact.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -483,8 +479,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our unrelated contact.
eppLoader.replaceAll("JD1234-REP", unrelatedContact.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
@Test
@ -494,8 +489,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
setEppInput("domain_info_with_contact_auth.xml");
// Replace the ROID in the xml file with the one for our unrelated contact.
eppLoader.replaceAll("JD1234-REP", unrelatedContact.getRepoId());
thrown.expect(BadAuthInfoForResourceException.class);
runFlow();
assertThrows(BadAuthInfoForResourceException.class, () -> runFlow());
}
/**
@ -574,8 +568,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_wrongCurrency() throws Exception {
setEppInput("domain_info_fee_create_euro.xml");
persistTestEntities(false);
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
/** Test requesting a period that isn't in years. */
@ -583,8 +576,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_periodNotInYears() throws Exception {
setEppInput("domain_info_fee_bad_period.xml");
persistTestEntities(false);
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
/** Test a command that specifies a phase. */
@ -592,8 +584,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_commandPhase() throws Exception {
setEppInput("domain_info_fee_command_phase.xml");
persistTestEntities(false);
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
/** Test a command that specifies a subphase. */
@ -601,8 +592,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_commandSubphase() throws Exception {
setEppInput("domain_info_fee_command_subphase.xml");
persistTestEntities(false);
thrown.expect(FeeChecksDontSupportPhasesException.class);
runFlow();
assertThrows(FeeChecksDontSupportPhasesException.class, () -> runFlow());
}
/** Test a restore for more than one year. */
@ -610,8 +600,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_multiyearRestore() throws Exception {
setEppInput("domain_info_fee_multiyear_restore.xml");
persistTestEntities(false);
thrown.expect(RestoresAreAlwaysForOneYearException.class);
runFlow();
assertThrows(RestoresAreAlwaysForOneYearException.class, () -> runFlow());
}
/** Test a transfer for more than one year. */
@ -619,8 +608,7 @@ public class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Dom
public void testFeeExtension_multiyearTransfer() throws Exception {
setEppInput("domain_info_fee_multiyear_transfer.xml");
persistTestEntities(false);
thrown.expect(TransfersAreAlwaysForOneYearException.class);
runFlow();
assertThrows(TransfersAreAlwaysForOneYearException.class, () -> runFlow());
}
/** Test that we load contacts and hosts as a batch rather than individually. */

View file

@ -27,6 +27,8 @@ import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.EUR;
@ -291,72 +293,63 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
public void testFailure_refundableFee_v06() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_06_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v11() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_11_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v12() throws Exception {
setEppInput("domain_renew_fee_refundable.xml", FEE_12_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v06() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_06_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v11() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_11_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v12() throws Exception {
setEppInput("domain_renew_fee_grace_period.xml", FEE_12_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v06() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_06_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v11() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_11_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v12() throws Exception {
setEppInput("domain_renew_fee_applied.xml", FEE_12_MAP);
persistDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -410,33 +403,33 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_clientRenewProhibited() throws Exception {
persistDomain(StatusValue.CLIENT_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientRenewProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("clientRenewProhibited");
}
@Test
public void testFailure_serverRenewProhibited() throws Exception {
persistDomain(StatusValue.SERVER_RENEW_PROHIBITED);
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverRenewProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverRenewProhibited");
}
@Test
@ -446,9 +439,9 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test
@ -460,8 +453,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.build());
persistDomain();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -473,8 +465,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.build());
persistDomain();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -486,8 +477,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.build());
persistDomain();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -504,8 +494,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistDomain();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -522,8 +511,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistDomain();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -540,32 +528,28 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
persistDomain();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_06_MAP);
persistDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_11_MAP);
persistDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception {
setEppInput("domain_renew_fee_bad_scale.xml", FEE_12_MAP);
persistDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
@ -575,25 +559,23 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2001-09-08T22:00:00.0Z"))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingTransfer");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingTransfer");
}
@Test
public void testFailure_periodInMonths() throws Exception {
setEppInput("domain_renew_months.xml");
persistDomain();
thrown.expect(BadPeriodUnitException.class);
runFlow();
assertThrows(BadPeriodUnitException.class, () -> runFlow());
}
@Test
public void testFailure_max10Years() throws Exception {
setEppInput("domain_renew_11_years.xml");
persistDomain();
thrown.expect(ExceedsMaxRegistrationYearsException.class);
runFlow();
assertThrows(ExceedsMaxRegistrationYearsException.class, () -> runFlow());
}
@Test
@ -603,16 +585,14 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
persistResource(reloadResourceByForeignKey().asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2000-04-04T22:00:00.0Z"))
.build());
thrown.expect(IncorrectCurrentExpirationDateException.class);
runFlow();
assertThrows(IncorrectCurrentExpirationDateException.class, () -> runFlow());
}
@Test
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -628,8 +608,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistDomain();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -647,8 +626,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
persistResource(Registry.get("example").asBuilder().setPremiumPriceAckRequired(true).build());
setEppInput("domain_renew_premium.xml");
persistDomain();
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
assertThrows(FeesRequiredForPremiumNameException.class, () -> runFlow());
}
@Test

View file

@ -27,6 +27,8 @@ import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
import static google.registry.testing.DatastoreHelper.persistReservedList;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@ -232,72 +234,63 @@ public class DomainRestoreRequestFlowTest extends
public void testFailure_refundableFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_refundableFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_gracePeriodFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
public void testFailure_appliedFee_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP);
persistPendingDeleteDomain();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow();
assertThrows(UnsupportedFeeAttributeException.class, () -> runFlow());
}
@Test
@ -340,9 +333,9 @@ public class DomainRestoreRequestFlowTest extends
@Test
public void testFailure_doesNotExist() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -351,8 +344,7 @@ public class DomainRestoreRequestFlowTest extends
persistPendingDeleteDomain();
persistResource(
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -361,8 +353,7 @@ public class DomainRestoreRequestFlowTest extends
persistPendingDeleteDomain();
persistResource(
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
@Test
@ -371,8 +362,7 @@ public class DomainRestoreRequestFlowTest extends
persistPendingDeleteDomain();
persistResource(
Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build());
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
private void runWrongCurrencyTest(Map<String, String> substitutions) throws Exception {
@ -388,8 +378,7 @@ public class DomainRestoreRequestFlowTest extends
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
thrown.expect(CurrencyUnitMismatchException.class);
runFlow();
assertThrows(CurrencyUnitMismatchException.class, () -> runFlow());
}
@Test
@ -411,24 +400,21 @@ public class DomainRestoreRequestFlowTest extends
public void testFailure_feeGivenInWrongScale_v06() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP);
persistPendingDeleteDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP);
persistPendingDeleteDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception {
setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP);
persistPendingDeleteDomain();
thrown.expect(CurrencyValueScaleException.class);
runFlow();
assertThrows(CurrencyValueScaleException.class, () -> runFlow());
}
@Test
@ -439,70 +425,63 @@ public class DomainRestoreRequestFlowTest extends
.setDeletionTime(clock.nowUtc().plusDays(4))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
thrown.expect(DomainNotEligibleForRestoreException.class);
runFlow();
assertThrows(DomainNotEligibleForRestoreException.class, () -> runFlow());
}
@Test
public void testFailure_notDeleted() throws Exception {
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(DomainNotEligibleForRestoreException.class);
runFlow();
assertThrows(DomainNotEligibleForRestoreException.class, () -> runFlow());
}
@Test
public void testFailure_fullyDeleted() throws Exception {
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
runFlow();
assertThrows(ResourceDoesNotExistException.class, () -> runFlow());
}
@Test
public void testFailure_withChange() throws Exception {
persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_change.xml");
thrown.expect(RestoreCommandIncludesChangesException.class);
runFlow();
assertThrows(RestoreCommandIncludesChangesException.class, () -> runFlow());
}
@Test
public void testFailure_withAdd() throws Exception {
persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_add.xml");
thrown.expect(RestoreCommandIncludesChangesException.class);
runFlow();
assertThrows(RestoreCommandIncludesChangesException.class, () -> runFlow());
}
@Test
public void testFailure_withRemove() throws Exception {
persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_remove.xml");
thrown.expect(RestoreCommandIncludesChangesException.class);
runFlow();
assertThrows(RestoreCommandIncludesChangesException.class, () -> runFlow());
}
@Test
public void testFailure_withSecDnsExtension() throws Exception {
persistPendingDeleteDomain();
setEppInput("domain_update_restore_request_with_secdns.xml");
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistPendingDeleteDomain();
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
public void testSuccess_superuserUnauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistPendingDeleteDomain();
thrown.expect(ResourceNotOwnedException.class);
runFlowAssertResponse(loadFile("domain_update_response.xml"));
assertThrows(
ResourceNotOwnedException.class,
() -> runFlowAssertResponse(loadFile("domain_update_response.xml")));
}
@Test
@ -510,8 +489,7 @@ public class DomainRestoreRequestFlowTest extends
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistPendingDeleteDomain();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -530,8 +508,7 @@ public class DomainRestoreRequestFlowTest extends
persistPendingDeleteDomain();
// Modify the Registrar to block premium names.
persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build());
thrown.expect(PremiumNameBlockedException.class);
runFlow();
assertThrows(PremiumNameBlockedException.class, () -> runFlow());
}
@Test
@ -543,8 +520,7 @@ public class DomainRestoreRequestFlowTest extends
.setReservedLists(persistReservedList("tld-reserved", "example,FULLY_BLOCKED"))
.build());
persistPendingDeleteDomain();
thrown.expect(DomainReservedException.class);
runFlow();
assertThrows(DomainReservedException.class, () -> runFlow());
}
@Test
@ -552,8 +528,7 @@ public class DomainRestoreRequestFlowTest extends
createTld("example");
setEppInput("domain_update_restore_request_premium.xml");
persistPendingDeleteDomain();
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow();
assertThrows(FeesRequiredForPremiumNameException.class, () -> runFlow());
}
@Test

View file

@ -32,6 +32,8 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.USD;
@ -406,8 +408,9 @@ public class DomainTransferApproveFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_approve_contact_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_approve_contact_authinfo.xml"));
}
@Test
@ -416,89 +419,97 @@ public class DomainTransferApproveFlowTest
persistResource(domain.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_approve_domain_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_approve_domain_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_gainingClient() throws Exception {
setClientIdForFlow("NewRegistrar");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("domain_transfer_approve.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("domain_transfer_approve.xml"));
}
@Test
public void testFailure_deletedDomain() throws Exception {
persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("domain_transfer_approve.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_approve.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("domain_transfer_approve.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
doSuccessfulTest("tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml");
assertThrows(
NotAuthorizedForTldException.class,
() ->
doSuccessfulTest(
"tld", "domain_transfer_approve.xml", "domain_transfer_approve_response.xml"));
}
@Test

View file

@ -29,6 +29,8 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.collect.ImmutableList;
@ -211,8 +213,9 @@ public class DomainTransferCancelFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_cancel_contact_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_cancel_contact_authinfo.xml"));
}
@Test
@ -221,89 +224,94 @@ public class DomainTransferCancelFlowTest
domain = persistResource(domain.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_cancel_domain_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_cancel_domain_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_sponsoringClient() throws Exception {
setClientIdForFlow("TheRegistrar");
thrown.expect(NotTransferInitiatorException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotTransferInitiatorException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(NotTransferInitiatorException.class);
doFailingTest("domain_transfer_cancel.xml");
assertThrows(
NotTransferInitiatorException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
}
@Test
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_cancel.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_cancel.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
doSuccessfulTest("domain_transfer_cancel.xml", "domain_transfer_cancel_response.xml");
assertThrows(
NotAuthorizedForTldException.class,
() ->
doSuccessfulTest("domain_transfer_cancel.xml", "domain_transfer_cancel_response.xml"));
}
@Test

View file

@ -20,6 +20,8 @@ import static google.registry.testing.DatastoreHelper.deleteResource;
import static google.registry.testing.DatastoreHelper.getPollMessages;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
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;
@ -175,8 +177,9 @@ public class DomainTransferQueryFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_query_contact_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_query_contact_authinfo.xml"));
}
@Test
@ -185,39 +188,43 @@ public class DomainTransferQueryFlowTest
domain = persistResource(domain.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_query_domain_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_query_domain_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NoTransferHistoryToQueryException.class);
doFailingTest("domain_transfer_query.xml");
assertThrows(
NoTransferHistoryToQueryException.class, () -> doFailingTest("domain_transfer_query.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(NotAuthorizedToViewTransferException.class);
doFailingTest("domain_transfer_query.xml");
assertThrows(
NotAuthorizedToViewTransferException.class,
() -> doFailingTest("domain_transfer_query.xml"));
}
@Test
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_query.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_query.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test

View file

@ -31,6 +31,8 @@ import static google.registry.testing.DatastoreHelper.loadRegistrar;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.collect.ImmutableSet;
@ -174,8 +176,10 @@ public class DomainTransferRejectFlowTest
public void testFailure_notAuthorizedForTld() throws Exception {
persistResource(
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml");
assertThrows(
NotAuthorizedForTldException.class,
() ->
doSuccessfulTest("domain_transfer_reject.xml", "domain_transfer_reject_response.xml"));
}
@Test
@ -193,8 +197,9 @@ public class DomainTransferRejectFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_reject_contact_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_reject_contact_authinfo.xml"));
}
@Test
@ -204,81 +209,84 @@ public class DomainTransferRejectFlowTest
domain.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_reject_domain_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_reject_domain_authinfo.xml"));
}
@Test
public void testFailure_neverBeenTransferred() throws Exception {
changeTransferStatus(null);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_clientApproved() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_clientRejected() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_REJECTED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_clientCancelled() throws Exception {
changeTransferStatus(TransferStatus.CLIENT_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_serverApproved() throws Exception {
changeTransferStatus(TransferStatus.SERVER_APPROVED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_serverCancelled() throws Exception {
changeTransferStatus(TransferStatus.SERVER_CANCELLED);
thrown.expect(NotPendingTransferException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
NotPendingTransferException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_gainingClient() throws Exception {
setClientIdForFlow("NewRegistrar");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_unrelatedClient() throws Exception {
setClientIdForFlow("ClientZ");
thrown.expect(ResourceNotOwnedException.class);
doFailingTest("domain_transfer_reject.xml");
assertThrows(
ResourceNotOwnedException.class, () -> doFailingTest("domain_transfer_reject.xml"));
}
@Test
public void testFailure_deletedDomain() throws Exception {
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
deleteResource(domain);
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_reject.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class, () -> doFailingTest("domain_transfer_reject.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
// NB: No need to test pending delete status since pending transfers will get cancelled upon

View file

@ -33,6 +33,8 @@ import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DomainResourceSubject.assertAboutDomains;
import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.stream.Collectors.toSet;
import static org.joda.money.CurrencyUnit.EUR;
@ -643,64 +645,73 @@ public class DomainTransferRequestFlowTest
@Test
public void testFailure_refundableFee_v06() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_06_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_06_MAP));
}
@Test
public void testFailure_refundableFee_v11() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_11_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_11_MAP));
}
@Test
public void testFailure_refundableFee_v12() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_12_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_refundable.xml", FEE_12_MAP));
}
@Test
public void testFailure_gracePeriodFee_v06() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_06_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_06_MAP));
}
@Test
public void testFailure_gracePeriodFee_v11() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_11_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_11_MAP));
}
@Test
public void testFailure_gracePeriodFee_v12() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_12_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_grace_period.xml", FEE_12_MAP));
}
@Test
public void testFailure_appliedFee_v06() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_applied.xml", FEE_06_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_06_MAP));
}
@Test
public void testFailure_appliedFee_v11() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_applied.xml", FEE_11_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_11_MAP));
}
@Test
public void testFailure_appliedFee_v12() throws Exception {
setupDomain("example", "tld");
thrown.expect(UnsupportedFeeAttributeException.class);
doFailingTest("domain_transfer_request_fee_applied.xml", FEE_12_MAP);
assertThrows(
UnsupportedFeeAttributeException.class,
() -> doFailingTest("domain_transfer_request_fee_applied.xml", FEE_12_MAP));
}
@Test
@ -739,8 +750,9 @@ public class DomainTransferRequestFlowTest
public void testFailure_multiYearPeriod() throws Exception {
setupDomain("example", "tld");
clock.advanceOneMilli();
thrown.expect(TransferPeriodMustBeOneYearException.class);
doFailingTest("domain_transfer_request_2_years.xml");
assertThrows(
TransferPeriodMustBeOneYearException.class,
() -> doFailingTest("domain_transfer_request_2_years.xml"));
}
@Test
@ -826,11 +838,13 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli();
thrown.expect(InvalidTransferPeriodValueException.class);
runTest(
"domain_transfer_request_superuser_extension.xml",
UserPrivileges.SUPERUSER,
ImmutableMap.of("PERIOD", "2", "AUTOMATIC_TRANSFER_LENGTH", "5"));
assertThrows(
InvalidTransferPeriodValueException.class,
() ->
runTest(
"domain_transfer_request_superuser_extension.xml",
UserPrivileges.SUPERUSER,
ImmutableMap.of("PERIOD", "2", "AUTOMATIC_TRANSFER_LENGTH", "5")));
}
@Test
@ -838,11 +852,13 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
eppRequestSource = EppRequestSource.TOOL;
clock.advanceOneMilli();
thrown.expect(TransferPeriodZeroAndFeeTransferExtensionException.class);
runTest(
"domain_transfer_request_fee_and_superuser_extension.xml",
UserPrivileges.SUPERUSER,
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5"));
assertThrows(
TransferPeriodZeroAndFeeTransferExtensionException.class,
() ->
runTest(
"domain_transfer_request_fee_and_superuser_extension.xml",
UserPrivileges.SUPERUSER,
ImmutableMap.of("PERIOD", "0", "AUTOMATIC_TRANSFER_LENGTH", "5")));
}
@Test
@ -894,8 +910,11 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
persistResource(
loadRegistrar("NewRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
thrown.expect(NotAuthorizedForTldException.class);
doSuccessfulTest("domain_transfer_request.xml", "domain_transfer_request_response.xml");
assertThrows(
NotAuthorizedForTldException.class,
() ->
doSuccessfulTest(
"domain_transfer_request.xml", "domain_transfer_request_response.xml"));
}
@Test
@ -1035,8 +1054,9 @@ public class DomainTransferRequestFlowTest
.setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
.setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build());
thrown.expect(CurrencyUnitMismatchException.class);
doFailingTest("domain_transfer_request_fee.xml", substitutions);
assertThrows(
CurrencyUnitMismatchException.class,
() -> doFailingTest("domain_transfer_request_fee.xml", substitutions));
}
@Test
@ -1060,22 +1080,25 @@ public class DomainTransferRequestFlowTest
@Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception {
setupDomain("example", "tld");
thrown.expect(CurrencyValueScaleException.class);
doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_06_MAP);
assertThrows(
CurrencyValueScaleException.class,
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_06_MAP));
}
@Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception {
setupDomain("example", "tld");
thrown.expect(CurrencyValueScaleException.class);
doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_11_MAP);
assertThrows(
CurrencyValueScaleException.class,
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_11_MAP));
}
@Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception {
setupDomain("example", "tld");
thrown.expect(CurrencyValueScaleException.class);
doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_12_MAP);
assertThrows(
CurrencyValueScaleException.class,
() -> doFailingTest("domain_transfer_request_fee_bad_scale.xml", FEE_12_MAP));
}
private void runWrongFeeAmountTest(Map<String, String> substitutions) throws Exception {
@ -1084,8 +1107,9 @@ public class DomainTransferRequestFlowTest
.asBuilder()
.setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 20)))
.build());
thrown.expect(FeesMismatchException.class);
doFailingTest("domain_transfer_request_fee.xml", substitutions);
assertThrows(
FeesMismatchException.class,
() -> doFailingTest("domain_transfer_request_fee.xml", substitutions));
}
@Test
@ -1112,22 +1136,25 @@ public class DomainTransferRequestFlowTest
// Modify the Registrar to block premium names.
persistResource(
loadRegistrar("NewRegistrar").asBuilder().setBlockPremiumNames(true).build());
thrown.expect(PremiumNameBlockedException.class);
doFailingTest("domain_transfer_request_premium.xml");
assertThrows(
PremiumNameBlockedException.class,
() -> doFailingTest("domain_transfer_request_premium.xml"));
}
@Test
public void testFailure_feeNotProvidedOnPremiumName() throws Exception {
setupDomain("rich", "example");
thrown.expect(FeesRequiredForPremiumNameException.class);
doFailingTest("domain_transfer_request_premium.xml");
assertThrows(
FeesRequiredForPremiumNameException.class,
() -> doFailingTest("domain_transfer_request_premium.xml"));
}
@Test
public void testFailure_noAuthInfo() throws Exception {
setupDomain("example", "tld");
thrown.expect(MissingTransferRequestAuthInfoException.class);
doFailingTest("domain_transfer_request_no_authinfo.xml");
assertThrows(
MissingTransferRequestAuthInfoException.class,
() -> doFailingTest("domain_transfer_request_no_authinfo.xml"));
}
@Test
@ -1138,8 +1165,8 @@ public class DomainTransferRequestFlowTest
contact.asBuilder()
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_request.xml");
assertThrows(
BadAuthInfoForResourceException.class, () -> doFailingTest("domain_transfer_request.xml"));
}
@Test
@ -1148,8 +1175,8 @@ public class DomainTransferRequestFlowTest
// Set the contact to a different ROID, but don't persist it; this is just so the substitution
// code above will write the wrong ROID into the file.
contact = contact.asBuilder().setRepoId("DEADBEEF_TLD-ROID").build();
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_request.xml");
assertThrows(
BadAuthInfoForResourceException.class, () -> doFailingTest("domain_transfer_request.xml"));
}
@Test
@ -1196,8 +1223,8 @@ public class DomainTransferRequestFlowTest
.setPendingTransferExpirationTime(clock.nowUtc().plusDays(1))
.build())
.build());
thrown.expect(AlreadyPendingTransferException.class);
doFailingTest("domain_transfer_request.xml");
assertThrows(
AlreadyPendingTransferException.class, () -> doFailingTest("domain_transfer_request.xml"));
}
@Test
@ -1207,16 +1234,17 @@ public class DomainTransferRequestFlowTest
domain = persistResource(domain.asBuilder()
.setAuthInfo(DomainAuthInfo.create(PasswordAuth.create("badpassword")))
.build());
thrown.expect(BadAuthInfoForResourceException.class);
doFailingTest("domain_transfer_request_domain_authinfo.xml");
assertThrows(
BadAuthInfoForResourceException.class,
() -> doFailingTest("domain_transfer_request_domain_authinfo.xml"));
}
@Test
public void testFailure_sponsoringClient() throws Exception {
setupDomain("example", "tld");
setClientIdForFlow("TheRegistrar");
thrown.expect(ObjectAlreadySponsoredException.class);
doFailingTest("domain_transfer_request.xml");
assertThrows(
ObjectAlreadySponsoredException.class, () -> doFailingTest("domain_transfer_request.xml"));
}
@Test
@ -1224,9 +1252,11 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
doFailingTest("domain_transfer_request.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("domain_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -1237,25 +1267,29 @@ 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);
thrown.expectMessage("(--invalid)");
runFlow(CommitMode.LIVE, UserPrivileges.NORMAL);
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> runFlow(CommitMode.LIVE, UserPrivileges.NORMAL));
assertThat(thrown).hasMessageThat().contains("(--invalid)");
}
@Test
public void testFailure_nonexistentDomain() throws Exception {
createTld("tld");
contact = persistActiveContact("jd1234");
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", "example.tld"));
doFailingTest("domain_transfer_request.xml");
ResourceDoesNotExistException thrown =
expectThrows(
ResourceDoesNotExistException.class,
() -> doFailingTest("domain_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", "example.tld"));
}
@Test
public void testFailure_periodInMonths() throws Exception {
setupDomain("example", "tld");
thrown.expect(BadPeriodUnitException.class);
doFailingTest("domain_transfer_request_months.xml");
assertThrows(
BadPeriodUnitException.class, () -> doFailingTest("domain_transfer_request_months.xml"));
}
@Test
@ -1263,9 +1297,11 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.CLIENT_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("clientTransferProhibited");
doFailingTest("domain_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("domain_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("clientTransferProhibited");
}
@Test
@ -1273,9 +1309,11 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.SERVER_TRANSFER_PROHIBITED).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverTransferProhibited");
doFailingTest("domain_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("domain_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("serverTransferProhibited");
}
@Test
@ -1283,9 +1321,11 @@ public class DomainTransferRequestFlowTest
setupDomain("example", "tld");
domain = persistResource(
domain.asBuilder().addStatusValue(StatusValue.PENDING_DELETE).build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
doFailingTest("domain_transfer_request.xml");
ResourceStatusProhibitsOperationException thrown =
expectThrows(
ResourceStatusProhibitsOperationException.class,
() -> doFailingTest("domain_transfer_request.xml"));
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test

View file

@ -440,8 +440,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_metadata.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(OnlyToolCanPassMetadataException.class);
runFlow();
assertThrows(OnlyToolCanPassMetadataException.class, () -> runFlow());
}
@Test
@ -795,8 +794,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setDsData(builder.build())
.build());
thrown.expect(TooManyDsRecordsException.class);
runFlow();
assertThrows(TooManyDsRecordsException.class, () -> runFlow());
}
@Test
@ -806,8 +804,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistDomain();
// Modify domain so it has 13 nameservers. We will then try to add one in the test.
modifyDomainToHave13Nameservers();
thrown.expect(TooManyNameserversException.class);
runFlow();
assertThrows(TooManyNameserversException.class, () -> runFlow());
}
@Test
@ -815,25 +812,24 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_wrong_extension.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(UnimplementedExtensionException.class);
runFlow();
assertThrows(UnimplementedExtensionException.class, () -> runFlow());
}
@Test
public void testFailure_neverExisted() throws Exception {
persistReferencedEntities();
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistReferencedEntities();
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -842,9 +838,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveContact("sh8013");
persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(ns2.example.foo)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns2.example.foo)");
}
@Test
@ -853,9 +849,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistActiveHost("ns2.example.foo");
persistActiveContact("mak21");
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect(LinkedResourcesDoNotExistException.class);
thrown.expectMessage("(sh8013)");
runFlow();
LinkedResourcesDoNotExistException thrown =
expectThrows(LinkedResourcesDoNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(sh8013)");
}
@Test
@ -871,8 +867,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
DesignatedContact.create(Type.TECH, Key.create(
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc())))))
.build());
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -880,8 +875,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_prohibited_status.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(StatusNotClientSettableException.class);
runFlow();
assertThrows(StatusNotClientSettableException.class, () -> runFlow());
}
@Test
@ -941,8 +935,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceHasClientUpdateProhibitedException.class);
runFlow();
assertThrows(ResourceHasClientUpdateProhibitedException.class, () -> runFlow());
}
@Test
@ -952,9 +945,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
newDomainResource(getUniqueIdFromCommand()).asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
}
@Test
@ -965,9 +958,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test
@ -975,8 +968,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_duplicate_contact.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(DuplicateContactForRoleException.class);
runFlow();
assertThrows(DuplicateContactForRoleException.class, () -> runFlow());
}
@Test
@ -985,8 +977,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_missing_contact_type.xml");
persistReferencedEntities();
persistDomain();
thrown.expect(MissingContactTypeException.class);
runFlow();
assertThrows(MissingContactTypeException.class, () -> runFlow());
}
@Test
@ -994,8 +985,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
sessionMetadata.setClientId("NewRegistrar");
persistReferencedEntities();
persistDomain();
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -1014,8 +1004,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build());
persistReferencedEntities();
persistDomain();
thrown.expect(NotAuthorizedForTldException.class);
runFlow();
assertThrows(NotAuthorizedForTldException.class, () -> runFlow());
}
@Test
@ -1038,8 +1027,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setNameservers(ImmutableSet.of(Key.create(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
.build());
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -1053,8 +1041,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
Key.create(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
.build());
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -1067,8 +1054,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
thrown.expect(MissingAdminContactException.class);
runFlow();
assertThrows(MissingAdminContactException.class, () -> runFlow());
}
@Test
@ -1081,8 +1067,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
DesignatedContact.create(Type.ADMIN, Key.create(sh8013Contact)),
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact))))
.build());
thrown.expect(MissingTechnicalContactException.class);
runFlow();
assertThrows(MissingTechnicalContactException.class, () -> runFlow());
}
@Test
@ -1096,9 +1081,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("mak21");
runFlow();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
expectThrows(
LinkedResourceInPendingDeleteProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("mak21");
}
@Test
@ -1113,9 +1099,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli();
thrown.expect(LinkedResourceInPendingDeleteProhibitsOperationException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
expectThrows(
LinkedResourceInPendingDeleteProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
}
@Test
@ -1127,8 +1114,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setAllowedRegistrantContactIds(ImmutableSet.of("contact1234"))
.build());
clock.advanceOneMilli();
thrown.expect(RegistrantNotAllowedException.class);
runFlow();
assertThrows(RegistrantNotAllowedException.class, () -> runFlow());
}
@Test
@ -1140,8 +1126,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
.build());
clock.advanceOneMilli();
thrown.expect(NameserversNotAllowedForTldException.class);
runFlow();
assertThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
}
@Test
@ -1223,8 +1208,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
Registry.get("tld").asBuilder()
.setAllowedFullyQualifiedHostNames(ImmutableSet.of("ns1.example.foo"))
.build());
thrown.expect(NameserversNotSpecifiedForTldWithNameserverWhitelistException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForTldWithNameserverWhitelistException.class, () -> runFlow());
}
@Test
@ -1252,9 +1237,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
}
@Test
@ -1269,8 +1254,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build());
thrown.expect(NameserversNotSpecifiedForNameserverRestrictedDomainException.class);
runFlow();
assertThrows(
NameserversNotSpecifiedForNameserverRestrictedDomainException.class, () -> runFlow());
}
@Test
@ -1314,9 +1299,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns3.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
}
@Test
@ -1349,9 +1334,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
.setReservedLists(
persistReservedList("reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForDomainException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
NameserversNotAllowedForDomainException thrown =
expectThrows(NameserversNotAllowedForDomainException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
}
@Test
@ -1367,9 +1352,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "example,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build());
thrown.expect(NameserversNotAllowedForTldException.class);
thrown.expectMessage("ns2.example.foo");
runFlow();
NameserversNotAllowedForTldException thrown =
expectThrows(NameserversNotAllowedForTldException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.foo");
}
@Test
@ -1387,8 +1372,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
runFlow();
assertThrows(DomainNotAllowedForTldWithCreateRestrictionException.class, () -> runFlow());
}
@Test
@ -1403,8 +1387,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
persistReservedList(
"reserved", "lol,NAMESERVER_RESTRICTED,ns1.example.foo:ns2.example.foo"))
.build());
thrown.expect(DomainNotAllowedForTldWithCreateRestrictionException.class);
runFlow();
assertThrows(DomainNotAllowedForTldWithCreateRestrictionException.class, () -> runFlow());
}
@Test
@ -1458,8 +1441,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistReferencedEntities();
persistDomain();
thrown.expect(FeesMismatchException.class);
runFlow();
assertThrows(FeesMismatchException.class, () -> runFlow());
}
// This test should throw an exception, because the fee extension is required when the fee is not
@ -1469,8 +1451,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
setEppInput("domain_update_wildcard.xml", ImmutableMap.of("DOMAIN", "non-free-update.tld"));
persistReferencedEntities();
persistDomain();
thrown.expect(FeesRequiredForNonFreeOperationException.class);
runFlow();
assertThrows(FeesRequiredForNonFreeOperationException.class, () -> runFlow());
}
@Test

View file

@ -17,6 +17,7 @@ package google.registry.flows.host;
import static google.registry.model.eppoutput.CheckData.HostCheck.create;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException;
@ -75,8 +76,7 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
@Test
public void testTooManyIds() throws Exception {
setEppInput("host_check_51.xml");
thrown.expect(TooManyResourceChecksException.class);
runFlow();
assertThrows(TooManyResourceChecksException.class, () -> runFlow());
}
@Test

View file

@ -26,6 +26,7 @@ import static google.registry.testing.DatastoreHelper.persistDeletedHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
@ -125,8 +126,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
createTlds("bar.tld", "tld");
setEppHostCreateInputWithIps("ns1.bar.tld");
thrown.expect(HostNameTooShallowException.class);
runFlow();
assertThrows(HostNameTooShallowException.class, () -> runFlow());
}
@Test
@ -154,8 +154,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
setEppHostCreateInput("ns1.example.tld", null);
createTld("tld");
persistActiveDomain("example.tld");
thrown.expect(SubordinateHostMustHaveIpException.class);
runFlow();
assertThrows(SubordinateHostMustHaveIpException.class, () -> runFlow());
}
@Test
@ -163,17 +162,16 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
setEppHostCreateInputWithIps("ns1.example.external");
createTld("tld");
persistActiveDomain("example.tld");
thrown.expect(UnexpectedExternalHostIpException.class);
runFlow();
assertThrows(UnexpectedExternalHostIpException.class, () -> runFlow());
}
@Test
public void testFailure_superordinateMissing() throws Exception {
setEppHostCreateInput("ns1.example.tld", null);
createTld("tld");
thrown.expect(SuperordinateDomainDoesNotExistException.class);
thrown.expectMessage("(example.tld)");
runFlow();
SuperordinateDomainDoesNotExistException thrown =
expectThrows(SuperordinateDomainDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(example.tld)");
}
@Test
@ -186,48 +184,49 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
clock.advanceOneMilli();
thrown.expect(SuperordinateDomainInPendingDeleteException.class);
thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
runFlow();
SuperordinateDomainInPendingDeleteException thrown =
expectThrows(SuperordinateDomainInPendingDeleteException.class, () -> runFlow());
assertThat(thrown)
.hasMessageThat()
.contains("Superordinate domain for this hostname is in pending delete");
}
@Test
public void testFailure_alreadyExists() throws Exception {
setEppHostCreateInput("ns1.example.tld", null);
persistActiveHost(getUniqueIdFromCommand());
thrown.expect(ResourceAlreadyExistsException.class);
thrown.expectMessage(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow();
ResourceAlreadyExistsException thrown =
expectThrows(ResourceAlreadyExistsException.class, () -> runFlow());
assertThat(thrown)
.hasMessageThat()
.contains(
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonLowerCaseHostname() throws Exception {
setEppHostCreateInput("ns1.EXAMPLE.tld", null);
thrown.expect(HostNameNotLowerCaseException.class);
runFlow();
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
}
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppHostCreateInput("ns1.çauçalito.みんな", null);
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.xn--q9jyb4c");
runFlow();
HostNameNotPunyCodedException thrown =
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.xn--q9jyb4c");
}
@Test
public void testFailure_nonCanonicalHostname() throws Exception {
setEppHostCreateInput("ns1.example.tld.", null);
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
}
@Test
public void testFailure_longHostName() throws Exception {
setEppHostCreateInputWithIps("a" + Strings.repeat(".labelpart", 25) + ".tld");
thrown.expect(HostNameTooLongException.class);
runFlow();
assertThrows(HostNameTooLongException.class, () -> runFlow());
}
@Test
@ -237,8 +236,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
"<host:addr ip=\"v4\">192.0.2.2</host:addr>\n"
+ "<host:addr ip=\"v6\">192.0.2.29</host:addr>\n"
+ "<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
thrown.expect(IpAddressVersionMismatchException.class);
runFlow();
assertThrows(IpAddressVersionMismatchException.class, () -> runFlow());
}
private void doFailingHostNameTest(String hostName, Class<? extends Throwable> exception)
@ -281,8 +279,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
public void testFailure_ccTldInBailiwick() throws Exception {
createTld("co.uk");
setEppHostCreateInputWithIps("foo.co.uk");
thrown.expect(HostNameTooShallowException.class);
runFlow();
assertThrows(HostNameTooShallowException.class, () -> runFlow());
}
@Test

View file

@ -24,6 +24,7 @@ import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistDeletedHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import static google.registry.testing.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
@ -83,17 +84,17 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns1.example.tld)");
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage("(ns1.example.tld)");
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(ns1.example.tld)");
}
private void doFailingStatusTest(StatusValue statusValue, Class<? extends Exception> exception)
@ -129,8 +130,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveHost("ns1.example.tld");
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -181,8 +181,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setPersistedCurrentSponsorClientId("TheRegistrar") // Shouldn't help.
.setSuperordinateDomain(Key.create(domain))
.build());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -237,8 +236,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setPersistedCurrentSponsorClientId("NewRegistrar") // Shouldn't help.
.setSuperordinateDomain(Key.create(domain))
.build());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -248,8 +246,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setNameservers(ImmutableSet.of(
Key.create(persistActiveHost("ns1.example.tld"))))
.build());
thrown.expect(ResourceToDeleteIsReferencedException.class);
runFlow();
assertThrows(ResourceToDeleteIsReferencedException.class, () -> runFlow());
}
@Test
@ -259,30 +256,27 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
.setNameservers(ImmutableSet.of(
Key.create(persistActiveHost("ns1.example.tld"))))
.build());
thrown.expect(ResourceToDeleteIsReferencedException.class);
runFlow();
assertThrows(ResourceToDeleteIsReferencedException.class, () -> runFlow());
}
@Test
public void testFailure_nonLowerCaseHostname() throws Exception {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
thrown.expect(HostNameNotLowerCaseException.class);
runFlow();
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
}
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
HostNameNotPunyCodedException thrown =
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
}
@Test
public void testFailure_nonCanonicalHostname() throws Exception {
setEppInput("host_delete.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
}
@Test

View file

@ -14,10 +14,13 @@
package google.registry.flows.host;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
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.JUnitBackports.assertThrows;
import static google.registry.testing.JUnitBackports.expectThrows;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@ -143,40 +146,38 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistResource(
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_nonLowerCaseHostname() throws Exception {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "NS1.EXAMPLE.NET"));
thrown.expect(HostNameNotLowerCaseException.class);
runFlow();
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
}
@Test
public void testFailure_nonPunyCodedHostname() throws Exception {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.çauçalito.tld"));
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
HostNameNotPunyCodedException thrown =
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
}
@Test
public void testFailure_nonCanonicalHostname() throws Exception {
setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld."));
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
}
@Test

View file

@ -408,8 +408,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
null,
null);
persistActiveHost(oldHostName());
thrown.expect(CannotRenameExternalHostException.class);
runFlow();
assertThrows(CannotRenameExternalHostException.class, () -> runFlow());
}
@Test
@ -760,9 +759,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_superordinateMissing() throws Exception {
createTld("tld");
persistActiveHost(oldHostName());
thrown.expect(SuperordinateDomainDoesNotExistException.class);
thrown.expectMessage("(example.tld)");
runFlow();
SuperordinateDomainDoesNotExistException thrown =
expectThrows(SuperordinateDomainDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("(example.tld)");
}
@Test
@ -781,32 +780,34 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.build());
persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
thrown.expect(SuperordinateDomainInPendingDeleteException.class);
thrown.expectMessage("Superordinate domain for this hostname is in pending delete");
runFlow();
SuperordinateDomainInPendingDeleteException thrown =
expectThrows(SuperordinateDomainInPendingDeleteException.class, () -> runFlow());
assertThat(thrown)
.hasMessageThat()
.contains("Superordinate domain for this hostname is in pending delete");
}
@Test
public void testFailure_neverExisted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_neverExisted_updateWithoutNameChange() throws Exception {
setEppInput("host_update_name_unchanged.xml");
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
thrown.expect(ResourceDoesNotExistException.class);
thrown.expectMessage(String.format("(%s)", getUniqueIdFromCommand()));
runFlow();
ResourceDoesNotExistException thrown =
expectThrows(ResourceDoesNotExistException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand()));
}
@Test
@ -815,9 +816,9 @@ 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);
thrown.expectMessage("ns1.example.tld");
runFlow();
HostAlreadyExistsException thrown =
expectThrows(HostAlreadyExistsException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns1.example.tld");
}
@Test
@ -825,57 +826,53 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistActiveHost("ns2.example.tld");
thrown.expect(HostAlreadyExistsException.class);
thrown.expectMessage("ns2.example.tld");
runFlow();
HostAlreadyExistsException thrown =
expectThrows(HostAlreadyExistsException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("ns2.example.tld");
}
@Test
public void testFailure_referToNonLowerCaseHostname() throws Exception {
setEppHostUpdateInput("ns1.EXAMPLE.tld", "ns2.example.tld", null, null);
thrown.expect(HostNameNotLowerCaseException.class);
runFlow();
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
}
@Test
public void testFailure_renameToNonLowerCaseHostname() throws Exception {
persistActiveHost("ns1.example.tld");
setEppHostUpdateInput("ns1.example.tld", "ns2.EXAMPLE.tld", null, null);
thrown.expect(HostNameNotLowerCaseException.class);
runFlow();
assertThrows(HostNameNotLowerCaseException.class, () -> runFlow());
}
@Test
public void testFailure_referToNonPunyCodedHostname() throws Exception {
setEppHostUpdateInput("ns1.çauçalito.tld", "ns1.sausalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
HostNameNotPunyCodedException thrown =
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
}
@Test
public void testFailure_renameToNonPunyCodedHostname() throws Exception {
persistActiveHost("ns1.sausalito.tld");
setEppHostUpdateInput("ns1.sausalito.tld", "ns1.çauçalito.tld", null, null);
thrown.expect(HostNameNotPunyCodedException.class);
thrown.expectMessage("expected ns1.xn--aualito-txac.tld");
runFlow();
HostNameNotPunyCodedException thrown =
expectThrows(HostNameNotPunyCodedException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("expected ns1.xn--aualito-txac.tld");
}
@Test
public void testFailure_referToNonCanonicalHostname() throws Exception {
persistActiveHost("ns1.example.tld.");
setEppHostUpdateInput("ns1.example.tld.", "ns2.example.tld", null, null);
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
}
@Test
public void testFailure_renameToNonCanonicalHostname() throws Exception {
persistActiveHost("ns1.example.tld");
setEppHostUpdateInput("ns1.example.tld", "ns2.example.tld.", null, null);
thrown.expect(HostNameNotNormalizedException.class);
runFlow();
assertThrows(HostNameNotNormalizedException.class, () -> runFlow());
}
@Test
@ -887,8 +884,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
thrown.expect(CannotRemoveSubordinateHostLastIpException.class);
runFlow();
assertThrows(CannotRemoveSubordinateHostLastIpException.class, () -> runFlow());
}
@Test
@ -900,8 +896,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
null);
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
thrown.expect(RenameHostToExternalRemoveIpException.class);
runFlow();
assertThrows(RenameHostToExternalRemoveIpException.class, () -> runFlow());
}
@Test
@ -913,8 +908,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
null);
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
thrown.expect(CannotAddIpToExternalHostException.class);
runFlow();
assertThrows(CannotAddIpToExternalHostException.class, () -> runFlow());
}
@Test
@ -927,8 +921,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
"<host:status s=\"clientUpdateProhibited\"/>",
"<host:status s=\"clientUpdateProhibited\"/>");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -940,8 +933,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
"ns2.example.tld",
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v4\">192.0.2.22</host:addr>");
thrown.expect(AddRemoveSameValueException.class);
runFlow();
assertThrows(AddRemoveSameValueException.class, () -> runFlow());
}
@Test
@ -965,8 +957,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build());
thrown.expect(ResourceHasClientUpdateProhibitedException.class);
runFlow();
assertThrows(ResourceHasClientUpdateProhibitedException.class, () -> runFlow());
}
@Test
@ -977,9 +968,9 @@ 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);
thrown.expectMessage("serverUpdateProhibited");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("serverUpdateProhibited");
}
@Test
@ -990,9 +981,9 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.setSuperordinateDomain(Key.create(persistActiveDomain("example.tld")))
.build());
thrown.expect(ResourceStatusProhibitsOperationException.class);
thrown.expectMessage("pendingDelete");
runFlow();
ResourceStatusProhibitsOperationException thrown =
expectThrows(ResourceStatusProhibitsOperationException.class, () -> runFlow());
assertThat(thrown).hasMessageThat().contains("pendingDelete");
}
@Test
@ -1000,8 +991,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
setEppInput("host_update_prohibited_status.xml");
thrown.expect(StatusNotClientSettableException.class);
runFlow();
assertThrows(StatusNotClientSettableException.class, () -> runFlow());
}
@Test
@ -1022,8 +1012,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
public void testFailure_unauthorizedClient() throws Exception {
sessionMetadata.setClientId("NewRegistrar");
persistActiveHost("ns1.example.tld");
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -1070,8 +1059,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
.build());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -1104,8 +1092,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
.setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1")))
.build());
thrown.expect(ResourceNotOwnedException.class);
runFlow();
assertThrows(ResourceNotOwnedException.class, () -> runFlow());
}
@Test
@ -1125,8 +1112,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
assertAboutHosts().that(host).hasPersistedCurrentSponsorClientId("TheRegistrar");
thrown.expect(HostDomainNotOwnedException.class);
runFlow();
assertThrows(HostDomainNotOwnedException.class, () -> runFlow());
}
@Test
@ -1146,8 +1132,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
assertAboutDomains().that(domain).hasPersistedCurrentSponsorClientId("TheRegistrar");
assertAboutHosts().that(host).hasPersistedCurrentSponsorClientId("TheRegistrar");
thrown.expect(HostDomainNotOwnedException.class);
runFlow();
assertThrows(HostDomainNotOwnedException.class, () -> runFlow());
}
@Test

View file

@ -20,6 +20,7 @@ import static google.registry.testing.DatastoreHelper.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveHost;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.JUnitBackports.assertThrows;
import com.google.common.collect.ImmutableList;
import google.registry.flows.FlowTestCase;
@ -220,7 +221,6 @@ public class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
public void testFailure_messageIdProvided() throws Exception {
setEppInput("poll_with_id.xml");
assertTransactionalFlow(false);
thrown.expect(UnexpectedMessageIdException.class);
runFlow();
assertThrows(UnexpectedMessageIdException.class, () -> runFlow());
}
}

View file

@ -15,6 +15,7 @@
package google.registry.flows.session;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.JUnitBackports.assertThrows;
import google.registry.flows.FlowTestCase;
import google.registry.flows.FlowUtils.NotLoggedInException;
@ -43,7 +44,6 @@ public class LogoutFlowTest extends FlowTestCase<LogoutFlow> {
@Test
public void testFailure() throws Exception {
sessionMetadata.setClientId(null); // Turn off the implicit login
thrown.expect(NotLoggedInException.class);
runFlow();
assertThrows(NotLoggedInException.class, () -> runFlow());
}
}