Move thrown.expect() right before runFlow() in one test file

This is how it should be in every test, but we used to not be
so careful about this. I had to touch this file anyways, so
I fixed it here.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135387267
This commit is contained in:
cgoldfeder 2016-10-06 12:01:29 -07:00 committed by Ben McIlwain
parent e864fedab1
commit 940fadff8a

View file

@ -384,19 +384,18 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_landrushApplicationReservedAllowedInSunrise() throws Exception { public void testFailure_landrushApplicationReservedAllowedInSunrise() throws Exception {
thrown.expect(DomainReservedException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setReservedLists(ImmutableSet.of(createReservedList())).build()); .setReservedLists(ImmutableSet.of(createReservedList())).build());
setEppInput("domain_create_landrush_allowedinsunrise.xml"); setEppInput("domain_create_landrush_allowedinsunrise.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(DomainReservedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationPremiumBlocked() throws Exception { public void testFailure_landrushApplicationPremiumBlocked() throws Exception {
thrown.expect(PremiumNameBlockedException.class);
createTld("example", TldState.SUNRUSH); createTld("example", TldState.SUNRUSH);
setEppInput("domain_create_landrush_premium.xml"); setEppInput("domain_create_landrush_premium.xml");
persistContactsAndHosts(); persistContactsAndHosts();
@ -405,16 +404,17 @@ public class DomainApplicationCreateFlowTest
persistResource(Registrar.loadByClientId("TheRegistrar").asBuilder() persistResource(Registrar.loadByClientId("TheRegistrar").asBuilder()
.setBlockPremiumNames(true) .setBlockPremiumNames(true)
.build()); .build());
thrown.expect(PremiumNameBlockedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushFeeNotProvidedOnPremiumName() throws Exception { public void testFailure_landrushFeeNotProvidedOnPremiumName() throws Exception {
thrown.expect(FeesRequiredForPremiumNameException.class);
createTld("example", TldState.SUNRUSH); createTld("example", TldState.SUNRUSH);
setEppInput("domain_create_landrush_premium.xml"); setEppInput("domain_create_landrush_premium.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow(); runFlow();
} }
@ -520,96 +520,96 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_landrushApplicationWithRefundableFee_v06() throws Exception { public void testFailure_landrushApplicationWithRefundableFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithRefundableFee_v11() throws Exception { public void testFailure_landrushApplicationWithRefundableFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput( setEppInput(
"domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11")); "domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithRefundableFee_v12() throws Exception { public void testFailure_landrushApplicationWithRefundableFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput( setEppInput(
"domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12")); "domain_create_landrush_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithGracePeriodFee_v06() throws Exception { public void testFailure_landrushApplicationWithGracePeriodFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput( setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6")); "domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithGracePeriodFee_v11() throws Exception { public void testFailure_landrushApplicationWithGracePeriodFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput( setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11")); "domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithGracePeriodFee_v12() throws Exception { public void testFailure_landrushApplicationWithGracePeriodFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput( setEppInput(
"domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12")); "domain_create_landrush_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithAppliedFee_v06() throws Exception { public void testFailure_landrushApplicationWithAppliedFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithAppliedFee_v11() throws Exception { public void testFailure_landrushApplicationWithAppliedFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrushApplicationWithAppliedFee_v12() throws Exception { public void testFailure_landrushApplicationWithAppliedFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_landrush_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@ -713,75 +713,75 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_missingMarks() throws Exception { public void testFailure_missingMarks() throws Exception {
thrown.expect(LandrushApplicationDisallowedDuringSunriseException.class);
setEppInput("domain_create_sunrise_without_marks.xml"); setEppInput("domain_create_sunrise_without_marks.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(LandrushApplicationDisallowedDuringSunriseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_sunriseApplicationInLandrush() throws Exception { public void testFailure_sunriseApplicationInLandrush() throws Exception {
thrown.expect(SunriseApplicationDisallowedDuringLandrushException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_signed_mark.xml"); setEppInput("domain_create_landrush_signed_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SunriseApplicationDisallowedDuringLandrushException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_smdRevoked() throws Exception { public void testFailure_smdRevoked() throws Exception {
SignedMarkRevocationList.create(clock.nowUtc(), ImmutableMap.of(SMD_ID, clock.nowUtc())).save(); SignedMarkRevocationList.create(clock.nowUtc(), ImmutableMap.of(SMD_ID, clock.nowUtc())).save();
thrown.expect(SignedMarkRevokedErrorException.class);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SignedMarkRevokedErrorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_tooManyNameservers() throws Exception { public void testFailure_tooManyNameservers() throws Exception {
thrown.expect(TooManyNameserversException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
setEppInput("domain_create_sunrush_14_nameservers.xml"); setEppInput("domain_create_sunrush_14_nameservers.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(TooManyNameserversException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_secDnsMaxSigLife() throws Exception { public void testFailure_secDnsMaxSigLife() throws Exception {
thrown.expect(MaxSigLifeNotSupportedException.class);
setEppInput("domain_create_sunrise_with_secdns_maxsiglife.xml"); setEppInput("domain_create_sunrise_with_secdns_maxsiglife.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(MaxSigLifeNotSupportedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_secDnsTooManyDsRecords() throws Exception { public void testFailure_secDnsTooManyDsRecords() throws Exception {
thrown.expect(TooManyDsRecordsException.class);
setEppInput("domain_create_sunrise_signed_mark_with_secdns_9_records.xml"); setEppInput("domain_create_sunrise_signed_mark_with_secdns_9_records.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(TooManyDsRecordsException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongExtension() throws Exception { public void testFailure_wrongExtension() throws Exception {
thrown.expect(UnimplementedExtensionException.class);
setEppInput("domain_create_sunrise_wrong_extension.xml"); setEppInput("domain_create_sunrise_wrong_extension.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(UnimplementedExtensionException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_reserved() throws Exception { public void testFailure_reserved() throws Exception {
thrown.expect(DomainReservedException.class);
setEppInput("domain_create_sunrise_signed_mark_reserved.xml"); setEppInput("domain_create_sunrise_signed_mark_reserved.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(DomainReservedException.class);
runFlow(); runFlow();
} }
@ -831,12 +831,12 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_landrushWithOneSunriseApplication() throws Exception { public void testFailure_landrushWithOneSunriseApplication() throws Exception {
thrown.expect(UncontestedSunriseApplicationBlockedInLandrushException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush.xml"); setEppInput("domain_create_landrush.xml");
persistSunriseApplication(); persistSunriseApplication();
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(UncontestedSunriseApplicationBlockedInLandrushException.class);
runFlow(); runFlow();
} }
@ -1020,95 +1020,95 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_landrushWithPeriodInMonths() throws Exception { public void testFailure_landrushWithPeriodInMonths() throws Exception {
thrown.expect(BadPeriodUnitException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_months.xml"); setEppInput("domain_create_landrush_months.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(BadPeriodUnitException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingHost() throws Exception { public void testFailure_missingHost() throws Exception {
thrown.expect(LinkedResourcesDoNotExistException.class, "(ns2.example.net)");
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
thrown.expect(LinkedResourcesDoNotExistException.class, "(ns2.example.net)");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingContact() throws Exception { public void testFailure_missingContact() throws Exception {
thrown.expect(LinkedResourcesDoNotExistException.class, "(sh8013)");
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
thrown.expect(LinkedResourcesDoNotExistException.class, "(sh8013)");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongTld() throws Exception { public void testFailure_wrongTld() throws Exception {
thrown.expect(TldDoesNotExistException.class);
deleteTld("tld"); deleteTld("tld");
createTld("foo", TldState.SUNRISE); createTld("foo", TldState.SUNRISE);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(TldDoesNotExistException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_predelegation() throws Exception { public void testFailure_predelegation() throws Exception {
thrown.expect(BadCommandForRegistryPhaseException.class);
createTld("tld", TldState.PREDELEGATION); createTld("tld", TldState.PREDELEGATION);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_notAuthorizedForTld() throws Exception { public void testFailure_notAuthorizedForTld() throws Exception {
thrown.expect(NotAuthorizedForTldException.class);
DatastoreHelper.persistResource(Registrar.loadByClientId("TheRegistrar") DatastoreHelper.persistResource(Registrar.loadByClientId("TheRegistrar")
.asBuilder() .asBuilder()
.setAllowedTlds(ImmutableSet.<String>of()) .setAllowedTlds(ImmutableSet.<String>of())
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NotAuthorizedForTldException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_sunrush() throws Exception { public void testFailure_sunrush() throws Exception {
thrown.expect(LaunchPhaseMismatchException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(LaunchPhaseMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_quietPeriod() throws Exception { public void testFailure_quietPeriod() throws Exception {
thrown.expect(BadCommandForRegistryPhaseException.class);
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", TldState.QUIET_PERIOD);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_generalAvailability() throws Exception { public void testFailure_generalAvailability() throws Exception {
thrown.expect(BadCommandForRegistryPhaseException.class);
createTld("tld", TldState.GENERAL_AVAILABILITY); createTld("tld", TldState.GENERAL_AVAILABILITY);
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(BadCommandForRegistryPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongDeclaredPhase() throws Exception { public void testFailure_wrongDeclaredPhase() throws Exception {
thrown.expect(LaunchPhaseMismatchException.class);
setEppInput("domain_create_landrush_signed_mark.xml"); setEppInput("domain_create_landrush_signed_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(LaunchPhaseMismatchException.class);
runFlow(); runFlow();
} }
@ -1154,170 +1154,169 @@ public class DomainApplicationCreateFlowTest
@Test @Test
public void testFailure_duplicateContact() throws Exception { public void testFailure_duplicateContact() throws Exception {
thrown.expect(DuplicateContactForRoleException.class);
setEppInput("domain_create_sunrise_duplicate_contact.xml"); setEppInput("domain_create_sunrise_duplicate_contact.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(DuplicateContactForRoleException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingContactType() throws Exception { public void testFailure_missingContactType() throws Exception {
// We need to test for missing type, but not for invalid - the schema enforces that for us.
thrown.expect(MissingContactTypeException.class);
setEppInput("domain_create_sunrise_missing_contact_type.xml"); setEppInput("domain_create_sunrise_missing_contact_type.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
// We need to test for missing type, but not for invalid - the schema enforces that for us.
thrown.expect(MissingContactTypeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_noMatchingMarks() throws Exception { public void testFailure_noMatchingMarks() throws Exception {
thrown.expect(NoMarksFoundMatchingDomainException.class);
setEppInput("domain_create_sunrise_no_matching_marks.xml"); setEppInput("domain_create_sunrise_no_matching_marks.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_beforeMarkCreationTime() throws Exception { public void testFailure_beforeMarkCreationTime() throws Exception {
// If we move now back in time a bit, the mark will not have gone into effect yet. // If we move now back in time a bit, the mark will not have gone into effect yet.
thrown.expect(NoMarksFoundMatchingDomainException.class);
clock.setTo(DateTime.parse("2013-08-09T10:05:59Z").minusSeconds(1)); clock.setTo(DateTime.parse("2013-08-09T10:05:59Z").minusSeconds(1));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_atMarkExpirationTime() throws Exception { public void testFailure_atMarkExpirationTime() throws Exception {
// Move time forward to the mark expiration time. // Move time forward to the mark expiration time.
thrown.expect(NoMarksFoundMatchingDomainException.class);
clock.setTo(DateTime.parse("2017-07-23T22:00:00.000Z")); clock.setTo(DateTime.parse("2017-07-23T22:00:00.000Z"));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NoMarksFoundMatchingDomainException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_hexEncoding() throws Exception { public void testFailure_hexEncoding() throws Exception {
thrown.expect(Base64RequiredForEncodedSignedMarksException.class);
setEppInput("domain_create_sunrise_hex_encoding.xml"); setEppInput("domain_create_sunrise_hex_encoding.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(Base64RequiredForEncodedSignedMarksException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badEncoding() throws Exception { public void testFailure_badEncoding() throws Exception {
thrown.expect(SignedMarkEncodingErrorException.class);
setEppInput("domain_create_sunrise_bad_encoding.xml"); setEppInput("domain_create_sunrise_bad_encoding.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SignedMarkEncodingErrorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badEncodedXml() throws Exception { public void testFailure_badEncodedXml() throws Exception {
thrown.expect(SignedMarkParsingErrorException.class);
setEppInput("domain_create_sunrise_bad_encoded_xml.xml"); setEppInput("domain_create_sunrise_bad_encoded_xml.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SignedMarkParsingErrorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badIdn() throws Exception { public void testFailure_badIdn() throws Exception {
thrown.expect(InvalidIdnDomainLabelException.class);
createTld("xn--q9jyb4c", TldState.SUNRUSH); createTld("xn--q9jyb4c", TldState.SUNRUSH);
setEppInput("domain_create_sunrush_bad_idn_minna.xml"); setEppInput("domain_create_sunrush_bad_idn_minna.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(InvalidIdnDomainLabelException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badValidatorId() throws Exception { public void testFailure_badValidatorId() throws Exception {
thrown.expect(InvalidTrademarkValidatorException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
setEppInput("domain_create_sunrush_bad_validator_id.xml"); setEppInput("domain_create_sunrush_bad_validator_id.xml");
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(InvalidTrademarkValidatorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_signedMark() throws Exception { public void testFailure_signedMark() throws Exception {
thrown.expect(SignedMarksMustBeEncodedException.class);
setEppInput("domain_create_sunrise_signed_mark.xml"); setEppInput("domain_create_sunrise_signed_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SignedMarksMustBeEncodedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_codeMark() throws Exception { public void testFailure_codeMark() throws Exception {
thrown.expect(UnsupportedMarkTypeException.class);
setEppInput("domain_create_sunrise_code_with_mark.xml"); setEppInput("domain_create_sunrise_code_with_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(UnsupportedMarkTypeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_emptyEncodedMarkData() throws Exception { public void testFailure_emptyEncodedMarkData() throws Exception {
thrown.expect(SignedMarkParsingErrorException.class);
setEppInput("domain_create_sunrise_empty_encoded_signed_mark.xml"); setEppInput("domain_create_sunrise_empty_encoded_signed_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(SignedMarkParsingErrorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_signedMarkAndNotice() throws Exception { public void testFailure_signedMarkAndNotice() throws Exception {
thrown.expect(NoticeCannotBeUsedWithSignedMarkException.class);
setEppInput("domain_create_sunrise_signed_mark_and_notice.xml"); setEppInput("domain_create_sunrise_signed_mark_and_notice.xml");
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(NoticeCannotBeUsedWithSignedMarkException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_twoSignedMarks() throws Exception { public void testFailure_twoSignedMarks() throws Exception {
thrown.expect(TooManySignedMarksException.class);
setEppInput("domain_create_sunrise_two_signed_marks.xml"); setEppInput("domain_create_sunrise_two_signed_marks.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(TooManySignedMarksException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingClaimsNotice() throws Exception { public void testFailure_missingClaimsNotice() throws Exception {
thrown.expect(MissingClaimsNoticeException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistClaimsList(ImmutableMap.of("test-validate", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("test-validate", CLAIMS_KEY));
setEppInput("domain_create_sunrush.xml"); setEppInput("domain_create_sunrush.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(MissingClaimsNoticeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_claimsNoticeProvided_nameNotOnClaimsList() throws Exception { public void testFailure_claimsNoticeProvided_nameNotOnClaimsList() throws Exception {
thrown.expect(UnexpectedClaimsNoticeException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_claim_notice.xml"); setEppInput("domain_create_landrush_claim_notice.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(UnexpectedClaimsNoticeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_claimsNoticeProvided_claimsPeriodEnded() throws Exception { public void testFailure_claimsNoticeProvided_claimsPeriodEnded() throws Exception {
thrown.expect(ClaimsPeriodEndedException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_claim_notice.xml"); setEppInput("domain_create_landrush_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
@ -1325,108 +1324,108 @@ public class DomainApplicationCreateFlowTest
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setClaimsPeriodEnd(clock.nowUtc()) .setClaimsPeriodEnd(clock.nowUtc())
.build()); .build());
thrown.expect(ClaimsPeriodEndedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_expiredClaim() throws Exception { public void testFailure_expiredClaim() throws Exception {
thrown.expect(ExpiredClaimException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z")); clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z"));
setEppInput("domain_create_sunrush_claim_notice.xml"); setEppInput("domain_create_sunrush_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(ExpiredClaimException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_expiredAcceptance() throws Exception { public void testFailure_expiredAcceptance() throws Exception {
thrown.expect(AcceptedTooLongAgoException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z"));
setEppInput("domain_create_sunrush_claim_notice.xml"); setEppInput("domain_create_sunrush_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(AcceptedTooLongAgoException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_malformedTcnIdWrongLength() throws Exception { public void testFailure_malformedTcnIdWrongLength() throws Exception {
thrown.expect(MalformedTcnIdException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_sunrush_malformed_claim_notice1.xml"); setEppInput("domain_create_sunrush_malformed_claim_notice1.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(MalformedTcnIdException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_malformedTcnIdBadChar() throws Exception { public void testFailure_malformedTcnIdBadChar() throws Exception {
thrown.expect(MalformedTcnIdException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_sunrush_malformed_claim_notice2.xml"); setEppInput("domain_create_sunrush_malformed_claim_notice2.xml");
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(MalformedTcnIdException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badTcnIdChecksum() throws Exception { public void testFailure_badTcnIdChecksum() throws Exception {
thrown.expect(InvalidTcnIdChecksumException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_sunrush_bad_checksum_claim_notice.xml"); setEppInput("domain_create_sunrush_bad_checksum_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(InvalidTcnIdChecksumException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeLandrushApplication_v06() throws Exception { public void testFailure_wrongFeeLandrushApplication_v06() throws Exception {
thrown.expect(FeesMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistResource( persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeLandrushApplication_v11() throws Exception { public void testFailure_wrongFeeLandrushApplication_v11() throws Exception {
thrown.expect(FeesMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistResource( persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeLandrushApplication_v12() throws Exception { public void testFailure_wrongFeeLandrushApplication_v12() throws Exception {
thrown.expect(FeesMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistResource( persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(FeesMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongCurrency_v06() throws Exception { public void testFailure_wrongCurrency_v06() throws Exception {
thrown.expect(CurrencyUnitMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
@ -1439,12 +1438,12 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongCurrency_v11() throws Exception { public void testFailure_wrongCurrency_v11() throws Exception {
thrown.expect(CurrencyUnitMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
@ -1457,12 +1456,12 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongCurrency_v12() throws Exception { public void testFailure_wrongCurrency_v12() throws Exception {
thrown.expect(CurrencyUnitMismatchException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
@ -1475,49 +1474,50 @@ public class DomainApplicationCreateFlowTest
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyUnitMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception { public void testFailure_feeGivenInWrongScale_v06() throws Exception {
thrown.expect(CurrencyValueScaleException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v11() throws Exception { public void testFailure_feeGivenInWrongScale_v11() throws Exception {
thrown.expect(CurrencyValueScaleException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v12() throws Exception { public void testFailure_feeGivenInWrongScale_v12() throws Exception {
thrown.expect(CurrencyValueScaleException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_landrush_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(CurrencyValueScaleException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_alreadyExists() throws Exception { public void testFailure_alreadyExists() throws Exception {
// This fails fast and throws DomainAlreadyExistsException from init() as a special case.
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
persistActiveDomain(getUniqueIdFromCommand()); persistActiveDomain(getUniqueIdFromCommand());
try { try {
// This fails fast and throws DomainAlreadyExistsException from init() as a special case.
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
runFlow(); runFlow();
} catch (ResourceAlreadyExistsException e) { } catch (ResourceAlreadyExistsException e) {
assertThat(e.isFailfast()).isTrue(); assertThat(e.isFailfast()).isTrue();
@ -1578,15 +1578,15 @@ public class DomainApplicationCreateFlowTest
*/ */
private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus) private void doNonFailFastAlreadyExistsTest(GracePeriodStatus gracePeriodStatus)
throws Exception { throws Exception {
// This doesn't fail fast, so it throws the regular ResourceAlreadyExistsException from run().
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
persistContactsAndHosts(); persistContactsAndHosts();
clock.advanceOneMilli(); clock.advanceOneMilli();
persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder() persistResource(newDomainResource(getUniqueIdFromCommand()).asBuilder()
.addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null)) .addGracePeriod(GracePeriod.create(gracePeriodStatus, END_OF_TIME, "", null))
.build()); .build());
// This doesn't fail fast, so it throws the regular ResourceAlreadyExistsException from run().
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
try { try {
runFlow(); runFlow();
} catch (ResourceAlreadyExistsException e) { } catch (ResourceAlreadyExistsException e) {
@ -1607,10 +1607,10 @@ public class DomainApplicationCreateFlowTest
private void doFailingDomainNameTest(String domainName, Class<? extends Throwable> exception) private void doFailingDomainNameTest(String domainName, Class<? extends Throwable> exception)
throws Exception { throws Exception {
thrown.expect(exception);
setEppInput("domain_create_sunrise_signed_mark_uppercase.xml"); setEppInput("domain_create_sunrise_signed_mark_uppercase.xml");
eppLoader.replaceAll("TEST-VALIDATE.tld", domainName); eppLoader.replaceAll("TEST-VALIDATE.tld", domainName);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(exception);
runFlow(); runFlow();
} }