diff --git a/javatests/google/registry/flows/domain/DomainCheckFlowTest.java b/javatests/google/registry/flows/domain/DomainCheckFlowTest.java index 413137597..908f87336 100644 --- a/javatests/google/registry/flows/domain/DomainCheckFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCheckFlowTest.java @@ -24,7 +24,8 @@ import static google.registry.testing.DatastoreHelper.persistDeletedDomain; import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistReservedList; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.testing.JUnitBackports.assertThrows; +import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; +import static google.registry.testing.JUnitBackports.expectThrows; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.USD; @@ -32,6 +33,8 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.Ordering; +import google.registry.flows.EppException; import google.registry.flows.ResourceCheckFlowTestCase; import google.registry.flows.domain.DomainCheckFlow.OnlyCheckedNamesCanBeFeeCheckedException; import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException; @@ -76,13 +79,13 @@ public class DomainCheckFlowTest } private ReservedList createReservedList() throws Exception { - return persistReservedList( - "tld-reserved", - "reserved,FULLY_BLOCKED", - "anchor,RESERVED_FOR_ANCHOR_TENANT,foo2BAR", - "allowedinsunrise,ALLOWED_IN_SUNRISE", - "collision,NAME_COLLISION", - "premiumcollision,NAME_COLLISION"); + return persistReservedList( + "tld-reserved", + "reserved,FULLY_BLOCKED", + "anchor,RESERVED_FOR_ANCHOR_TENANT,foo2BAR", + "allowedinsunrise,ALLOWED_IN_SUNRISE", + "collision,NAME_COLLISION", + "premiumcollision,NAME_COLLISION"); } @Before @@ -148,8 +151,9 @@ public class DomainCheckFlowTest persistResource( Registry.get("tld.foo") .asBuilder() - .setReservedLists(persistReservedList( - "tld.foo", "reserved,FULLY_BLOCKED", "allowedinsunrise,ALLOWED_IN_SUNRISE")) + .setReservedLists( + persistReservedList( + "tld.foo", "reserved,FULLY_BLOCKED", "allowedinsunrise,ALLOWED_IN_SUNRISE")) .build()); setEppInput("domain_check_one_multipart_tld_reserved.xml"); doCheckTest( @@ -171,9 +175,7 @@ public class DomainCheckFlowTest @Test public void testSuccess_duplicatesAllowed() throws Exception { setEppInput("domain_check_duplicates.xml"); - doCheckTest( - create(true, "example1.tld", null), - create(true, "example1.tld", null)); + doCheckTest(create(true, "example1.tld", null), create(true, "example1.tld", null)); } @Test @@ -192,8 +194,7 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingSunriseApplicationInGeneralAvailability() throws Exception { createTld("tld", TldState.GENERAL_AVAILABILITY); - persistResource(newDomainApplication("example2.tld").asBuilder() - .build()); + persistResource(newDomainApplication("example2.tld").asBuilder().build()); doCheckTest( create(true, "example1.tld", null), create(false, "example2.tld", "Pending allocation"), @@ -203,9 +204,8 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingLandrushApplicationInGeneralAvailability() throws Exception { createTld("tld", TldState.GENERAL_AVAILABILITY); - persistResource(newDomainApplication("example2.tld").asBuilder() - .setPhase(LaunchPhase.LANDRUSH) - .build()); + persistResource( + newDomainApplication("example2.tld").asBuilder().setPhase(LaunchPhase.LANDRUSH).build()); doCheckTest( create(true, "example1.tld", null), create(false, "example2.tld", "Pending allocation"), @@ -215,8 +215,7 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingSunriseApplicationInQuietPeriod() throws Exception { createTld("tld", TldState.QUIET_PERIOD); - persistResource(newDomainApplication("example2.tld").asBuilder() - .build()); + persistResource(newDomainApplication("example2.tld").asBuilder().build()); doCheckTest( create(true, "example1.tld", null), create(false, "example2.tld", "Pending allocation"), @@ -226,9 +225,8 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingLandrushApplicationInQuietPeriod() throws Exception { createTld("tld", TldState.QUIET_PERIOD); - persistResource(newDomainApplication("example2.tld").asBuilder() - .setPhase(LaunchPhase.LANDRUSH) - .build()); + persistResource( + newDomainApplication("example2.tld").asBuilder().setPhase(LaunchPhase.LANDRUSH).build()); doCheckTest( create(true, "example1.tld", null), create(false, "example2.tld", "Pending allocation"), @@ -238,8 +236,7 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingSunriseApplicationInSunrise() throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(newDomainApplication("example2.tld").asBuilder() - .build()); + persistResource(newDomainApplication("example2.tld").asBuilder().build()); doCheckTest( create(true, "example1.tld", null), create(true, "example2.tld", null), @@ -249,9 +246,8 @@ public class DomainCheckFlowTest @Test public void testSuccess_pendingLandrushApplicationInLandrush() throws Exception { createTld("tld", TldState.LANDRUSH); - persistResource(newDomainApplication("example2.tld").asBuilder() - .setPhase(LaunchPhase.LANDRUSH) - .build()); + persistResource( + newDomainApplication("example2.tld").asBuilder().setPhase(LaunchPhase.LANDRUSH).build()); doCheckTest( create(true, "example1.tld", null), create(true, "example2.tld", null), @@ -261,10 +257,12 @@ public class DomainCheckFlowTest @Test public void testSuccess_rejectedApplication() throws Exception { createTld("tld", TldState.LANDRUSH); - persistResource(newDomainApplication("example2.tld").asBuilder() - .setPhase(LaunchPhase.LANDRUSH) - .setApplicationStatus(ApplicationStatus.REJECTED) - .build()); + persistResource( + newDomainApplication("example2.tld") + .asBuilder() + .setPhase(LaunchPhase.LANDRUSH) + .setApplicationStatus(ApplicationStatus.REJECTED) + .build()); doCheckTest( create(true, "example1.tld", null), create(true, "example2.tld", null), @@ -274,20 +272,23 @@ public class DomainCheckFlowTest @Test public void testFailure_tooManyIds() throws Exception { setEppInput("domain_check_51.xml"); - assertThrows(TooManyResourceChecksException.class, this::runFlow); + EppException thrown = expectThrows(TooManyResourceChecksException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_wrongTld() throws Exception { setEppInput("domain_check.xml"); - assertThrows(TldDoesNotExistException.class, this::runFlow); + EppException thrown = expectThrows(TldDoesNotExistException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_notAuthorizedForTld() throws Exception { persistResource( loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); - assertThrows(NotAuthorizedForTldException.class, this::runFlow); + EppException thrown = expectThrows(NotAuthorizedForTldException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -299,10 +300,11 @@ public class DomainCheckFlowTest CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_check_one_tld_response.xml")); } - private void doFailingBadLabelTest(String label, Class expectedException) + private void doFailingBadLabelTest(String label, Class expectedException) throws Exception { setEppInput("domain_check_template.xml", ImmutableMap.of("LABEL", label)); - assertThrows(expectedException, this::runFlow); + EppException thrown = expectThrows(expectedException, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -386,7 +388,8 @@ public class DomainCheckFlowTest @Test public void testFailure_predelegation() throws Exception { createTld("tld", TldState.PREDELEGATION); - assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); + EppException thrown = expectThrows(BadCommandForRegistryPhaseException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -461,7 +464,8 @@ public class DomainCheckFlowTest /** * Test commands for create, renew, transfer, restore and update with implicit period and - * currency. */ + * currency. + */ @Test public void testFeeExtension_multipleCommands_v06() throws Exception { setEppInput("domain_check_fee_multiple_commands_v06.xml"); @@ -531,9 +535,11 @@ public class DomainCheckFlowTest // Note that the response xml expects to see "11.10" with two digits after the decimal point. // This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to // display the number of digits that is conventional for the given currency. - persistResource(Registry.get("tld").asBuilder() - .setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1)) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1)) + .build()); setEppInput("domain_check_fee_fractional.xml"); runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml")); } @@ -541,10 +547,12 @@ public class DomainCheckFlowTest /** Test that create fees are properly omitted/classed on names on reserved lists. */ @Test public void testFeeExtension_reservedName_v06() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v06.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v06.xml")); } @@ -552,50 +560,60 @@ public class DomainCheckFlowTest /** The tests must be split up for version 11, which allows only one command at a time. */ @Test public void testFeeExtension_reservedName_v11_create() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_create.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_create.xml")); } @Test public void testFeeExtension_reservedName_v11_renew() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_renew.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_renew.xml")); } @Test public void testFeeExtension_reservedName_v11_transfer() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_transfer.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_transfer.xml")); } @Test public void testFeeExtension_reservedName_v11_restore() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_restore.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v11_restore.xml")); } @Test public void testFeeExtension_reservedName_v12() throws Exception { - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v12.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_response_v12.xml")); } @@ -603,58 +621,67 @@ public class DomainCheckFlowTest @Test public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v06() throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v06.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v06.xml")); } @Test - public void - testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_create() throws Exception { + public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_create() + throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_create.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_create.xml")); } @Test - public void - testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_renew() throws Exception { + public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_renew() throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_renew.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_renew.xml")); } @Test - public void - testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_transfer() throws Exception { + public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_transfer() + throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_transfer.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_transfer.xml")); } @Test - public void - testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_restore() throws Exception { + public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v11_restore() + throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v11_restore.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v11_restore.xml")); } @@ -662,10 +689,12 @@ public class DomainCheckFlowTest @Test public void testFeeExtension_feesNotOmittedOnReservedNamesInSunrise_v12() throws Exception { createTld("tld", TldState.SUNRISE); - persistResource(Registry.get("tld").asBuilder() - .setReservedLists(createReservedList()) - .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setReservedLists(createReservedList()) + .setPremiumList(persistPremiumList("tld", "premiumcollision,USD 70")) + .build()); setEppInput("domain_check_fee_reserved_v12.xml"); runFlowAssertResponse(loadFile("domain_check_fee_reserved_sunrise_response_v12.xml")); } @@ -673,164 +702,194 @@ public class DomainCheckFlowTest @Test public void testFeeExtension_wrongCurrency_v06() throws Exception { setEppInput("domain_check_fee_euro_v06.xml"); - assertThrows(CurrencyUnitMismatchException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_wrongCurrency_v11() throws Exception { setEppInput("domain_check_fee_euro_v11.xml"); - assertThrows(CurrencyUnitMismatchException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_wrongCurrency_v12() throws Exception { setEppInput("domain_check_fee_euro_v12.xml"); - assertThrows(CurrencyUnitMismatchException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_periodNotInYears_v06() throws Exception { setEppInput("domain_check_fee_bad_period_v06.xml"); - assertThrows(BadPeriodUnitException.class, this::runFlow); + EppException thrown = expectThrows(BadPeriodUnitException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_periodNotInYears_v11() throws Exception { setEppInput("domain_check_fee_bad_period_v11.xml"); - assertThrows(BadPeriodUnitException.class, this::runFlow); + EppException thrown = expectThrows(BadPeriodUnitException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_periodNotInYears_v12() throws Exception { setEppInput("domain_check_fee_bad_period_v12.xml"); - assertThrows(BadPeriodUnitException.class, this::runFlow); + EppException thrown = expectThrows(BadPeriodUnitException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandWithPhase_v06() throws Exception { setEppInput("domain_check_fee_command_phase_v06.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandWithPhase_v11() throws Exception { setEppInput("domain_check_fee_command_phase_v11.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandWithPhase_v12() throws Exception { setEppInput("domain_check_fee_command_phase_v12.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandSubphase_v06() throws Exception { setEppInput("domain_check_fee_command_subphase_v06.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandSubphase_v11() throws Exception { setEppInput("domain_check_fee_command_subphase_v11.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_commandSubphase_v12() throws Exception { setEppInput("domain_check_fee_command_subphase_v12.xml"); - assertThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + EppException thrown = expectThrows(FeeChecksDontSupportPhasesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } // 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"); - assertThrows(OnlyCheckedNamesCanBeFeeCheckedException.class, this::runFlow); + EppException thrown = + expectThrows(OnlyCheckedNamesCanBeFeeCheckedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearRestore_v06() throws Exception { setEppInput("domain_check_fee_multiyear_restore_v06.xml"); - assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearRestore_v11() throws Exception { setEppInput("domain_check_fee_multiyear_restore_v11.xml"); - assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearRestore_v12() throws Exception { setEppInput("domain_check_fee_multiyear_restore_v12.xml"); - assertThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(RestoresAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearTransfer_v06() throws Exception { setEppInput("domain_check_fee_multiyear_transfer_v06.xml"); - assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearTransfer_v11() throws Exception { setEppInput("domain_check_fee_multiyear_transfer_v11.xml"); - assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_multiyearTransfer_v12() throws Exception { setEppInput("domain_check_fee_multiyear_transfer_v12.xml"); - assertThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + EppException thrown = expectThrows(TransfersAreAlwaysForOneYearException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_unknownCommand_v06() throws Exception { setEppInput("domain_check_fee_unknown_command_v06.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_unknownCommand_v11() throws Exception { setEppInput("domain_check_fee_unknown_command_v11.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_unknownCommand_v12() throws Exception { setEppInput("domain_check_fee_unknown_command_v12.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_invalidCommand_v06() throws Exception { setEppInput("domain_check_fee_invalid_command_v06.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_invalidCommand_v11() throws Exception { setEppInput("domain_check_fee_invalid_command_v11.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFeeExtension_invalidCommand_v12() throws Exception { setEppInput("domain_check_fee_invalid_command_v12.xml"); - assertThrows(UnknownFeeCommandException.class, this::runFlow); + EppException thrown = expectThrows(UnknownFeeCommandException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } private void runEapFeeCheckTest(String inputFile, String outputFile) throws Exception { clock.setTo(DateTime.parse("2010-01-01T10:00:00Z")); persistActiveDomain("example1.tld"); - persistResource(Registry.get("tld").asBuilder() - .setEapFeeSchedule(ImmutableSortedMap.of( - START_OF_TIME, Money.of(USD, 0), - clock.nowUtc().minusDays(1), Money.of(USD, 100), - clock.nowUtc().plusDays(1), Money.of(USD, 50), - clock.nowUtc().plusDays(2), Money.of(USD, 0))) - .build()); + persistResource( + Registry.get("tld") + .asBuilder() + .setEapFeeSchedule( + new ImmutableSortedMap.Builder(Ordering.natural()) + .put(START_OF_TIME, Money.of(USD, 0)) + .put(clock.nowUtc().minusDays(1), Money.of(USD, 100)) + .put(clock.nowUtc().plusDays(1), Money.of(USD, 50)) + .put(clock.nowUtc().plusDays(2), Money.of(USD, 0)) + .build()) + .build()); setEppInput(inputFile); runFlowAssertResponse(loadFile(outputFile)); } @@ -852,8 +911,8 @@ public class DomainCheckFlowTest @Test public void testSuccess_eapFeeCheck_date_v12() throws Exception { - runEapFeeCheckTest("domain_check_fee_date_v12.xml", - "domain_check_eap_fee_response_date_v12.xml"); + runEapFeeCheckTest( + "domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml"); } @Ignore diff --git a/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java b/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java index b0bf55a4f..577c0ba12 100644 --- a/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainClaimsCheckFlowTest.java @@ -18,10 +18,12 @@ 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 static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; +import static google.registry.testing.JUnitBackports.expectThrows; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import google.registry.flows.EppException; import google.registry.flows.ResourceFlowTestCase; import google.registry.flows.domain.DomainClaimsCheckFlow.DomainClaimsCheckNotAllowedInSunrise; import google.registry.flows.domain.DomainFlowUtils.BadCommandForRegistryPhaseException; @@ -51,8 +53,8 @@ public class DomainClaimsCheckFlowTest protected void doSuccessfulTest(String expectedXmlFilename) throws Exception { assertTransactionalFlow(false); - assertNoHistory(); // Checks don't create a history event. - assertNoBillingEvents(); // Checks are always free. + assertNoHistory(); // Checks don't create a history event. + assertNoBillingEvents(); // Checks are always free. runFlowAssertResponse(loadFile(expectedXmlFilename)); } @@ -102,20 +104,23 @@ public class DomainClaimsCheckFlowTest @Test public void testFailure_TooManyIds() throws Exception { setEppInput("domain_check_claims_51.xml"); - assertThrows(TooManyResourceChecksException.class, this::runFlow); + EppException thrown = expectThrows(TooManyResourceChecksException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_tldDoesntExist() throws Exception { setEppInput("domain_check_claims_bad_tld.xml"); - assertThrows(TldDoesNotExistException.class, this::runFlow); + EppException thrown = expectThrows(TldDoesNotExistException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_notAuthorizedForTld() throws Exception { persistResource( loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); - assertThrows(NotAuthorizedForTldException.class, this::runFlow); + EppException thrown = expectThrows(NotAuthorizedForTldException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -136,7 +141,8 @@ public class DomainClaimsCheckFlowTest createTld("tld", TldState.PREDELEGATION); persistResource(Registry.get("tld").asBuilder().build()); setEppInput("domain_check_claims.xml"); - assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); + EppException thrown = expectThrows(BadCommandForRegistryPhaseException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -144,7 +150,8 @@ public class DomainClaimsCheckFlowTest createTld("tld", TldState.SUNRISE); persistResource(Registry.get("tld").asBuilder().build()); setEppInput("domain_check_claims.xml"); - assertThrows(DomainClaimsCheckNotAllowedInSunrise.class, this::runFlow); + EppException thrown = expectThrows(DomainClaimsCheckNotAllowedInSunrise.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -154,7 +161,8 @@ public class DomainClaimsCheckFlowTest persistResource( Registry.get("tld2").asBuilder().setClaimsPeriodEnd(clock.nowUtc().minusMillis(1)).build()); setEppInput("domain_check_claims_multiple_tlds.xml"); - assertThrows(ClaimsPeriodEndedException.class, this::runFlow); + EppException thrown = expectThrows(ClaimsPeriodEndedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test diff --git a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java index 22a6d92f7..c37722528 100644 --- a/javatests/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainCreateFlowTest.java @@ -43,7 +43,6 @@ 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.EppExceptionSubject.assertAboutEppExceptions; -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; @@ -60,6 +59,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; +import google.registry.flows.EppException; import google.registry.flows.EppException.UnimplementedExtensionException; import google.registry.flows.EppRequestSource; import google.registry.flows.ExtensionManager.UndeclaredServiceExtensionException; @@ -162,17 +162,21 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase billingFlags = isAnchorTenant - ? ImmutableSet.of(BillingEvent.Flag.ANCHOR_TENANT) - : ImmutableSet.of(); + DateTime billingTime = + isAnchorTenant + ? clock.nowUtc().plus(Registry.get(domainTld).getAnchorTenantAddGracePeriodLength()) + : clock.nowUtc().plus(Registry.get(domainTld).getAddGracePeriodLength()); + ImmutableSet billingFlags = + isAnchorTenant ? ImmutableSet.of(BillingEvent.Flag.ANCHOR_TENANT) : ImmutableSet.of(); HistoryEntry historyEntry = getHistoryEntries(domain).get(0); - assertAboutDomains().that(domain) + assertAboutDomains() + .that(domain) .hasRegistrationExpirationTime( - ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()).and() + ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()) + .and() .hasOnlyOneHistoryEntryWhich() - .hasType(HistoryEntry.Type.DOMAIN_CREATE).and() + .hasType(HistoryEntry.Type.DOMAIN_CREATE) + .and() .hasPeriodYears(2); // There should be one bill for the create and one for the recurring autorenew event. BillingEvent.OneTime createBillingEvent = @@ -268,11 +278,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase substitutions) throws Exception { + Map substitutions) + throws Exception { assertTransactionalFlow(true); runFlowAssertResponse( CommitMode.LIVE, userPrivileges, loadFile(responseXmlFile, substitutions)); @@ -337,9 +351,8 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase substitutions) throws Exception { + String domainTld, String responseXmlFile, Map substitutions) + throws Exception { doSuccessfulTest(domainTld, responseXmlFile, UserPrivileges.NORMAL, substitutions); } @@ -373,9 +386,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase exception) throws Exception { + private void doFailingDomainNameTest(String domainName, Class exception) + throws Exception { setEppInput("domain_create_uppercase.xml"); eppLoader.replaceAll("Example.tld", domainName); persistContactsAndHosts(); - assertThrows(exception, this::runFlow); + EppException thrown = expectThrows(exception, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -1476,7 +1583,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase substitutions) throws Exception { + Map substitutions) + throws Exception { // Persist the billing event so it can be retrieved for cancellation generation and checking. setUpSuccessfulTest(); BillingEvent.OneTime graceBillingEvent = @@ -339,12 +345,20 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase[]{}))) - .isEmpty(); + assertThat(oldTransferData.getServerApproveEntities()).isNotEmpty(); // Just a sanity check. + assertThat( + ofy().load().keys(oldTransferData.getServerApproveEntities().toArray(new Key[] {}))) + .isEmpty(); } @Test @@ -616,15 +651,15 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase substitutions, - Money totalRenewCost) throws Exception { + Money totalRenewCost) + throws Exception { assertTransactionalFlow(true); DateTime currentExpiration = reloadResourceByForeignKey().getRegistrationExpirationTime(); DateTime newExpiration = currentExpiration.plusYears(renewalYears); @@ -155,23 +163,26 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase { +public class DomainRestoreRequestFlowTest + extends ResourceFlowTestCase { private static final ImmutableMap FEE_06_MAP = ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee"); @@ -92,24 +93,31 @@ public class DomainRestoreRequestFlowTest extends void persistPendingDeleteDomain() throws Exception { DomainResource domain = newDomainResource(getUniqueIdFromCommand()); - HistoryEntry historyEntry = persistResource( - new HistoryEntry.Builder() - .setType(HistoryEntry.Type.DOMAIN_DELETE) - .setParent(domain) - .build()); - domain = persistResource(domain.asBuilder() - .setRegistrationExpirationTime(clock.nowUtc().plusYears(5).plusDays(45)) - .setDeletionTime(clock.nowUtc().plusDays(35)) - .addGracePeriod(GracePeriod.create( - GracePeriodStatus.REDEMPTION, clock.nowUtc().plusDays(1), "foo", null)) - .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) - .setDeletePollMessage(Key.create(persistResource( - new PollMessage.OneTime.Builder() - .setClientId("TheRegistrar") - .setEventTime(clock.nowUtc().plusDays(5)) - .setParent(historyEntry) - .build()))) - .build()); + HistoryEntry historyEntry = + persistResource( + new HistoryEntry.Builder() + .setType(HistoryEntry.Type.DOMAIN_DELETE) + .setParent(domain) + .build()); + domain = + persistResource( + domain + .asBuilder() + .setRegistrationExpirationTime(clock.nowUtc().plusYears(5).plusDays(45)) + .setDeletionTime(clock.nowUtc().plusDays(35)) + .addGracePeriod( + GracePeriod.create( + GracePeriodStatus.REDEMPTION, clock.nowUtc().plusDays(1), "foo", null)) + .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) + .setDeletePollMessage( + Key.create( + persistResource( + new PollMessage.OneTime.Builder() + .setClientId("TheRegistrar") + .setEventTime(clock.nowUtc().plusDays(5)) + .setParent(historyEntry) + .build()))) + .build()); clock.advanceOneMilli(); } @@ -126,22 +134,24 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); assertTransactionalFlow(true); // Double check that we see a poll message in the future for when the delete happens. - assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))) - .hasSize(1); + assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1); runFlowAssertResponse(loadFile("domain_update_response.xml")); DomainResource domain = reloadResourceByForeignKey(); HistoryEntry historyEntryDomainRestore = getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE); assertThat(ofy().load().key(domain.getAutorenewBillingEvent()).now().getEventTime()) .isEqualTo(clock.nowUtc().plusYears(1)); - assertAboutDomains().that(domain) + assertAboutDomains() + .that(domain) // New expiration time should be exactly a year from now. - .hasRegistrationExpirationTime(clock.nowUtc().plusYears(1)).and() - .doesNotHaveStatusValue(StatusValue.PENDING_DELETE).and() - .hasDeletionTime(END_OF_TIME).and() + .hasRegistrationExpirationTime(clock.nowUtc().plusYears(1)) + .and() + .doesNotHaveStatusValue(StatusValue.PENDING_DELETE) + .and() + .hasDeletionTime(END_OF_TIME) + .and() .hasOneHistoryEntryEachOfTypes( - HistoryEntry.Type.DOMAIN_DELETE, - HistoryEntry.Type.DOMAIN_RESTORE); + HistoryEntry.Type.DOMAIN_DELETE, HistoryEntry.Type.DOMAIN_RESTORE); assertThat(domain.getGracePeriods()).isEmpty(); assertDnsTasksEnqueued("example.tld"); // The poll message for the delete should now be gone. The only poll message should be the new @@ -209,6 +219,7 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); runFlowAssertResponse(loadFile("domain_update_restore_request_response_fee.xml", FEE_12_MAP)); } + @Test public void testSuccess_fee_withDefaultAttributes_v06() throws Exception { setEppInput("domain_update_restore_request_fee_defaults.xml", FEE_06_MAP); @@ -234,63 +245,72 @@ public class DomainRestoreRequestFlowTest extends public void testFailure_refundableFee_v06() throws Exception { setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_06_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_refundableFee_v11() throws Exception { setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_11_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_refundableFee_v12() throws Exception { setEppInput("domain_update_restore_request_fee_refundable.xml", FEE_12_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_gracePeriodFee_v06() throws Exception { setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_06_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_gracePeriodFee_v11() throws Exception { setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_11_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_gracePeriodFee_v12() throws Exception { setEppInput("domain_update_restore_request_fee_grace_period.xml", FEE_12_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_appliedFee_v06() throws Exception { setEppInput("domain_update_restore_request_fee_applied.xml", FEE_06_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_appliedFee_v11() throws Exception { setEppInput("domain_update_restore_request_fee_applied.xml", FEE_11_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_appliedFee_v12() throws Exception { setEppInput("domain_update_restore_request_fee_applied.xml", FEE_12_MAP); persistPendingDeleteDomain(); - assertThrows(UnsupportedFeeAttributeException.class, this::runFlow); + EppException thrown = expectThrows(UnsupportedFeeAttributeException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -311,9 +331,7 @@ public class DomainRestoreRequestFlowTest extends .build()); persistPendingDeleteDomain(); runFlowAssertResponse( - CommitMode.LIVE, - UserPrivileges.SUPERUSER, - loadFile("domain_update_response.xml")); + CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml")); } @Test @@ -323,12 +341,9 @@ public class DomainRestoreRequestFlowTest extends setEppInput("domain_update_restore_request_premium.xml"); persistPendingDeleteDomain(); // Modify the Registrar to block premium names. - persistResource( - loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build()); + persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build()); runFlowAssertResponse( - CommitMode.LIVE, - UserPrivileges.SUPERUSER, - loadFile("domain_update_response.xml")); + CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_update_response.xml")); } @Test @@ -344,7 +359,8 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); persistResource( Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build()); - assertThrows(FeesMismatchException.class, this::runFlow); + EppException thrown = expectThrows(FeesMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -353,7 +369,8 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); persistResource( Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build()); - assertThrows(FeesMismatchException.class, this::runFlow); + EppException thrown = expectThrows(FeesMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -362,7 +379,8 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); persistResource( Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 100)).build()); - assertThrows(FeesMismatchException.class, this::runFlow); + EppException thrown = expectThrows(FeesMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } private void runWrongCurrencyTest(Map substitutions) throws Exception { @@ -378,7 +396,8 @@ public class DomainRestoreRequestFlowTest extends .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR))) .setServerStatusChangeBillingCost(Money.of(EUR, 19)) .build()); - assertThrows(CurrencyUnitMismatchException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -400,21 +419,24 @@ public class DomainRestoreRequestFlowTest extends public void testFailure_feeGivenInWrongScale_v06() throws Exception { setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_06_MAP); persistPendingDeleteDomain(); - assertThrows(CurrencyValueScaleException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyValueScaleException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_feeGivenInWrongScale_v11() throws Exception { setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_11_MAP); persistPendingDeleteDomain(); - assertThrows(CurrencyValueScaleException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyValueScaleException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_feeGivenInWrongScale_v12() throws Exception { setEppInput("domain_update_restore_request_fee_bad_scale.xml", FEE_12_MAP); persistPendingDeleteDomain(); - assertThrows(CurrencyValueScaleException.class, this::runFlow); + EppException thrown = expectThrows(CurrencyValueScaleException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -425,63 +447,73 @@ public class DomainRestoreRequestFlowTest extends .setDeletionTime(clock.nowUtc().plusDays(4)) .setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE)) .build()); - assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow); + EppException thrown = expectThrows(DomainNotEligibleForRestoreException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_notDeleted() throws Exception { persistActiveDomain(getUniqueIdFromCommand()); - assertThrows(DomainNotEligibleForRestoreException.class, this::runFlow); + EppException thrown = expectThrows(DomainNotEligibleForRestoreException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_fullyDeleted() throws Exception { persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1)); - assertThrows(ResourceDoesNotExistException.class, this::runFlow); + EppException thrown = expectThrows(ResourceDoesNotExistException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_withChange() throws Exception { persistPendingDeleteDomain(); setEppInput("domain_update_restore_request_with_change.xml"); - assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + EppException thrown = expectThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_withAdd() throws Exception { persistPendingDeleteDomain(); setEppInput("domain_update_restore_request_with_add.xml"); - assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + EppException thrown = expectThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_withRemove() throws Exception { persistPendingDeleteDomain(); setEppInput("domain_update_restore_request_with_remove.xml"); - assertThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + EppException thrown = expectThrows(RestoreCommandIncludesChangesException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_withSecDnsExtension() throws Exception { persistPendingDeleteDomain(); setEppInput("domain_update_restore_request_with_secdns.xml"); - assertThrows(UnimplementedExtensionException.class, this::runFlow); + EppException thrown = expectThrows(UnimplementedExtensionException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testFailure_unauthorizedClient() throws Exception { sessionMetadata.setClientId("NewRegistrar"); persistPendingDeleteDomain(); - assertThrows(ResourceNotOwnedException.class, this::runFlow); + EppException thrown = expectThrows(ResourceNotOwnedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test public void testSuccess_superuserUnauthorizedClient() throws Exception { sessionMetadata.setClientId("NewRegistrar"); persistPendingDeleteDomain(); - assertThrows( - ResourceNotOwnedException.class, - () -> runFlowAssertResponse(loadFile("domain_update_response.xml"))); + EppException thrown = + expectThrows( + ResourceNotOwnedException.class, + () -> runFlowAssertResponse(loadFile("domain_update_response.xml"))); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -489,7 +521,8 @@ public class DomainRestoreRequestFlowTest extends persistResource( loadRegistrar("TheRegistrar").asBuilder().setAllowedTlds(ImmutableSet.of()).build()); persistPendingDeleteDomain(); - assertThrows(NotAuthorizedForTldException.class, this::runFlow); + EppException thrown = expectThrows(NotAuthorizedForTldException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -508,7 +541,8 @@ public class DomainRestoreRequestFlowTest extends persistPendingDeleteDomain(); // Modify the Registrar to block premium names. persistResource(loadRegistrar("TheRegistrar").asBuilder().setBlockPremiumNames(true).build()); - assertThrows(PremiumNameBlockedException.class, this::runFlow); + EppException thrown = expectThrows(PremiumNameBlockedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -520,7 +554,8 @@ public class DomainRestoreRequestFlowTest extends .setReservedLists(persistReservedList("tld-reserved", "example,FULLY_BLOCKED")) .build()); persistPendingDeleteDomain(); - assertThrows(DomainReservedException.class, this::runFlow); + EppException thrown = expectThrows(DomainReservedException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -528,7 +563,8 @@ public class DomainRestoreRequestFlowTest extends createTld("example"); setEppInput("domain_update_restore_request_premium.xml"); persistPendingDeleteDomain(); - assertThrows(FeesRequiredForPremiumNameException.class, this::runFlow); + EppException thrown = expectThrows(FeesRequiredForPremiumNameException.class, this::runFlow); + assertAboutEppExceptions().that(thrown).marshalsToXml(); } @Test @@ -537,7 +573,7 @@ public class DomainRestoreRequestFlowTest extends runFlow(); assertIcannReportingActivityFieldLogged("srs-dom-rgp-restore-request"); assertTldsFieldLogged("tld"); - } + } @Test public void testIcannTransactionReportField_getsStored() throws Exception {