Move thrown.expect() calls to line immediately before failing call

Plus some misc formatting cleanup

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=136817377
This commit is contained in:
ctingue 2016-10-21 04:01:38 -07:00 committed by Ben McIlwain
parent 4cfe107475
commit 5240773dd1
3 changed files with 85 additions and 85 deletions

View file

@ -409,73 +409,73 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_refundableFee_v06() throws Exception { public void testFailure_refundableFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_refundableFee_v11() throws Exception { public void testFailure_refundableFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_refundableFee_v12() throws Exception { public void testFailure_refundableFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee_refundable.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_gracePeriodFee_v06() throws Exception { public void testFailure_gracePeriodFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_gracePeriodFee_v11() throws Exception { public void testFailure_gracePeriodFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_gracePeriodFee_v12() throws Exception { public void testFailure_gracePeriodFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee_grace_period.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_appliedFee_v06() throws Exception { public void testFailure_appliedFee_v06() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_appliedFee_v11() throws Exception { public void testFailure_appliedFee_v11() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_appliedFee_v12() throws Exception { public void testFailure_appliedFee_v12() throws Exception {
thrown.expect(UnsupportedFeeAttributeException.class);
setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee_applied.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedFeeAttributeException.class);
runFlow(); runFlow();
} }
@ -494,9 +494,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_metadataNotFromTool() throws Exception { public void testFailure_metadataNotFromTool() throws Exception {
thrown.expect(OnlyToolCanPassMetadataException.class);
setEppInput("domain_create_metadata.xml"); setEppInput("domain_create_metadata.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(OnlyToolCanPassMetadataException.class);
runFlow(); runFlow();
} }
@ -594,9 +594,9 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_periodInMonths() throws Exception { public void testFailure_periodInMonths() throws Exception {
thrown.expect(BadPeriodUnitException.class);
setEppInput("domain_create_months.xml"); setEppInput("domain_create_months.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(BadPeriodUnitException.class);
runFlow(); runFlow();
} }
@ -626,96 +626,98 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_missingClaimsNotice() throws Exception { public void testFailure_missingClaimsNotice() throws Exception {
thrown.expect(MissingClaimsNoticeException.class);
persistClaimsList(ImmutableMap.of("example", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example", CLAIMS_KEY));
setEppInput("domain_create.xml"); setEppInput("domain_create.xml");
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_claim_notice.xml"); setEppInput("domain_create_claim_notice.xml");
persistClaimsList(ImmutableMap.<String, String>of()); persistClaimsList(ImmutableMap.<String, String>of());
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_claim_notice.xml"); setEppInput("domain_create_claim_notice.xml");
persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("example-one", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
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_tooManyNameservers() throws Exception { public void testFailure_tooManyNameservers() throws Exception {
thrown.expect(TooManyNameserversException.class);
setEppInput("domain_create_14_nameservers.xml"); setEppInput("domain_create_14_nameservers.xml");
persistContactsAndHosts(); persistContactsAndHosts();
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_dsdata.xml"); setEppInput("domain_create_dsdata.xml");
persistContactsAndHosts(); persistContactsAndHosts();
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_dsdata_9_records.xml"); setEppInput("domain_create_dsdata_9_records.xml");
persistContactsAndHosts(); persistContactsAndHosts();
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_wrong_extension.xml"); setEppInput("domain_create_wrong_extension.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnimplementedExtensionException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeAmount_v06() throws Exception { public void testFailure_wrongFeeAmount_v06() throws Exception {
thrown.expect(FeesMismatchException.class);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistResource(Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(FeesMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeAmount_v11() throws Exception { public void testFailure_wrongFeeAmount_v11() throws Exception {
thrown.expect(FeesMismatchException.class);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistResource(Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(FeesMismatchException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongFeeAmount_v12() throws Exception { public void testFailure_wrongFeeAmount_v12() throws Exception {
thrown.expect(FeesMismatchException.class);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistResource(Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build()); persistResource(
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setCurrency(CurrencyUnit.EUR) .setCurrency(CurrencyUnit.EUR)
@ -726,12 +728,12 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19)) .setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setCurrency(CurrencyUnit.EUR) .setCurrency(CurrencyUnit.EUR)
@ -742,12 +744,12 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19)) .setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistResource(Registry.get("tld").asBuilder() persistResource(Registry.get("tld").asBuilder()
.setCurrency(CurrencyUnit.EUR) .setCurrency(CurrencyUnit.EUR)
@ -758,17 +760,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setServerStatusChangeBillingCost(Money.of(EUR, 19)) .setServerStatusChangeBillingCost(Money.of(EUR, 19))
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(CurrencyUnitMismatchException.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. // This fails fast and throws DomainAlreadyExistsException from init() as a special case.
persistContactsAndHosts();
persistActiveDomain(getUniqueIdFromCommand());
thrown.expect( thrown.expect(
ResourceAlreadyExistsException.class, ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand())); String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
persistContactsAndHosts();
persistActiveDomain(getUniqueIdFromCommand());
try { try {
runFlow(); runFlow();
} catch (ResourceAlreadyExistsException e) { } catch (ResourceAlreadyExistsException e) {
@ -784,13 +787,13 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
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(). // 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();
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());
thrown.expect(
ResourceAlreadyExistsException.class,
String.format("Object with given ID (%s) already exists", getUniqueIdFromCommand()));
try { try {
runFlow(); runFlow();
} catch (ResourceAlreadyExistsException e) { } catch (ResourceAlreadyExistsException e) {
@ -811,17 +814,17 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_reserved() throws Exception { public void testFailure_reserved() throws Exception {
thrown.expect(DomainReservedException.class);
setEppInput("domain_create_reserved.xml"); setEppInput("domain_create_reserved.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(DomainReservedException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_anchorTenantViaAuthCode_wrongAuthCode() throws Exception { public void testFailure_anchorTenantViaAuthCode_wrongAuthCode() throws Exception {
thrown.expect(DomainReservedException.class);
setEppInput("domain_create_anchor_wrong_authcode.xml"); setEppInput("domain_create_anchor_wrong_authcode.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(DomainReservedException.class);
runFlow(); runFlow();
} }
@ -890,20 +893,17 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@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_pendingDeleteHost() throws Exception { public void testFailure_pendingDeleteHost() throws Exception {
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"ns2.example.net");
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
@ -911,15 +911,18 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"ns2.example.net");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_openApplication() throws Exception { public void testFailure_openApplication() throws Exception {
thrown.expect(DomainHasOpenApplicationsException.class);
persistContactsAndHosts(); persistContactsAndHosts();
persistActiveDomainApplication(getUniqueIdFromCommand()); persistActiveDomainApplication(getUniqueIdFromCommand());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(DomainHasOpenApplicationsException.class);
runFlow(); runFlow();
} }
@ -942,20 +945,17 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@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_pendingDeleteContact() throws Exception { public void testFailure_pendingDeleteContact() throws Exception {
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"jd1234");
persistActiveHost("ns1.example.net"); persistActiveHost("ns1.example.net");
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
@ -963,54 +963,57 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.addStatusValue(StatusValue.PENDING_DELETE) .addStatusValue(StatusValue.PENDING_DELETE)
.build()); .build());
clock.advanceOneMilli(); clock.advanceOneMilli();
thrown.expect(
LinkedResourceInPendingDeleteProhibitsOperationException.class,
"jd1234");
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_wrongTld() throws Exception { public void testFailure_wrongTld() throws Exception {
thrown.expect(TldDoesNotExistException.class);
persistContactsAndHosts("net"); persistContactsAndHosts("net");
deleteTld("tld"); deleteTld("tld");
thrown.expect(TldDoesNotExistException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_predelegation() throws Exception { public void testFailure_predelegation() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.PREDELEGATION); createTld("tld", TldState.PREDELEGATION);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_sunrise() throws Exception { public void testFailure_sunrise() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.SUNRISE); createTld("tld", TldState.SUNRISE);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_sunrush() throws Exception { public void testFailure_sunrush() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_landrush() throws Exception { public void testFailure_landrush() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_quietPeriod() throws Exception { public void testFailure_quietPeriod() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", TldState.QUIET_PERIOD);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@ -1054,135 +1057,134 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_duplicateContact() throws Exception { public void testFailure_duplicateContact() throws Exception {
thrown.expect(DuplicateContactForRoleException.class);
setEppInput("domain_create_duplicate_contact.xml"); setEppInput("domain_create_duplicate_contact.xml");
persistContactsAndHosts(); persistContactsAndHosts();
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. // We need to test for missing type, but not for invalid - the schema enforces that for us.
thrown.expect(MissingContactTypeException.class);
setEppInput("domain_create_missing_contact_type.xml"); setEppInput("domain_create_missing_contact_type.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MissingContactTypeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingRegistrant() throws Exception { public void testFailure_missingRegistrant() throws Exception {
thrown.expect(MissingRegistrantException.class);
setEppInput("domain_create_missing_registrant.xml"); setEppInput("domain_create_missing_registrant.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MissingRegistrantException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingAdmin() throws Exception { public void testFailure_missingAdmin() throws Exception {
thrown.expect(MissingAdminContactException.class);
setEppInput("domain_create_missing_admin.xml"); setEppInput("domain_create_missing_admin.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MissingAdminContactException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingTech() throws Exception { public void testFailure_missingTech() throws Exception {
thrown.expect(MissingTechnicalContactException.class);
setEppInput("domain_create_missing_tech.xml"); setEppInput("domain_create_missing_tech.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MissingTechnicalContactException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_missingNonRegistrantContacts() throws Exception { public void testFailure_missingNonRegistrantContacts() throws Exception {
thrown.expect(MissingAdminContactException.class);
setEppInput("domain_create_missing_non_registrant_contacts.xml"); setEppInput("domain_create_missing_non_registrant_contacts.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MissingAdminContactException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badIdn() throws Exception { public void testFailure_badIdn() throws Exception {
thrown.expect(InvalidIdnDomainLabelException.class);
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
setEppInput("domain_create_bad_idn_minna.xml"); setEppInput("domain_create_bad_idn_minna.xml");
persistContactsAndHosts("net"); persistContactsAndHosts("net");
thrown.expect(InvalidIdnDomainLabelException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badValidatorId() throws Exception { public void testFailure_badValidatorId() throws Exception {
thrown.expect(InvalidTrademarkValidatorException.class);
setEppInput("domain_create_bad_validator_id.xml"); setEppInput("domain_create_bad_validator_id.xml");
persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY)); persistClaimsList(ImmutableMap.of("exampleone", CLAIMS_KEY));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(InvalidTrademarkValidatorException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_codeMark() throws Exception { public void testFailure_codeMark() throws Exception {
thrown.expect(UnsupportedMarkTypeException.class);
setEppInput("domain_create_code_with_mark.xml"); setEppInput("domain_create_code_with_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UnsupportedMarkTypeException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_signedMark() throws Exception { public void testFailure_signedMark() throws Exception {
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
setEppInput("domain_create_signed_mark.xml"); setEppInput("domain_create_signed_mark.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_expiredClaim() throws Exception { public void testFailure_expiredClaim() throws Exception {
thrown.expect(ExpiredClaimException.class);
clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z")); clock.setTo(DateTime.parse("2010-08-17T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml"); setEppInput("domain_create_claim_notice.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(ExpiredClaimException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_expiredAcceptance() throws Exception { public void testFailure_expiredAcceptance() throws Exception {
thrown.expect(AcceptedTooLongAgoException.class);
clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-09-16T09:00:00.0Z"));
setEppInput("domain_create_claim_notice.xml"); setEppInput("domain_create_claim_notice.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(AcceptedTooLongAgoException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_malformedTcnIdWrongLength() throws Exception { public void testFailure_malformedTcnIdWrongLength() throws Exception {
thrown.expect(MalformedTcnIdException.class);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice1.xml"); setEppInput("domain_create_malformed_claim_notice1.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MalformedTcnIdException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_malformedTcnIdBadChar() throws Exception { public void testFailure_malformedTcnIdBadChar() throws Exception {
thrown.expect(MalformedTcnIdException.class);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_malformed_claim_notice2.xml"); setEppInput("domain_create_malformed_claim_notice2.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(MalformedTcnIdException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_badTcnIdChecksum() throws Exception { public void testFailure_badTcnIdChecksum() throws Exception {
thrown.expect(InvalidTcnIdChecksumException.class);
clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z")); clock.setTo(DateTime.parse("2009-08-16T09:00:00.0Z"));
setEppInput("domain_create_bad_checksum_claim_notice.xml"); setEppInput("domain_create_bad_checksum_claim_notice.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(InvalidTcnIdChecksumException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_premiumBlocked() throws Exception { public void testFailure_premiumBlocked() throws Exception {
thrown.expect(PremiumNameBlockedException.class);
createTld("example"); createTld("example");
persistResource(Registry.get("example").asBuilder().setPremiumPriceAckRequired(false).build()); persistResource(Registry.get("example").asBuilder().setPremiumPriceAckRequired(false).build());
setEppInput("domain_create_premium.xml"); setEppInput("domain_create_premium.xml");
@ -1191,85 +1193,86 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
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_feeNotProvidedOnPremiumName() throws Exception { public void testFailure_feeNotProvidedOnPremiumName() throws Exception {
thrown.expect(FeesRequiredForPremiumNameException.class);
createTld("example"); createTld("example");
setEppInput("domain_create_premium.xml"); setEppInput("domain_create_premium.xml");
persistContactsAndHosts("net"); persistContactsAndHosts("net");
thrown.expect(FeesRequiredForPremiumNameException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_omitFeeExtensionOnLogin_v06() throws Exception { public void testFailure_omitFeeExtensionOnLogin_v06() throws Exception {
thrown.expect(UndeclaredServiceExtensionException.class);
for (String uri : FEE_EXTENSION_URIS) { for (String uri : FEE_EXTENSION_URIS) {
removeServiceExtensionUri(uri); removeServiceExtensionUri(uri);
} }
createTld("net"); createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_omitFeeExtensionOnLogin_v11() throws Exception { public void testFailure_omitFeeExtensionOnLogin_v11() throws Exception {
thrown.expect(UndeclaredServiceExtensionException.class);
for (String uri : FEE_EXTENSION_URIS) { for (String uri : FEE_EXTENSION_URIS) {
removeServiceExtensionUri(uri); removeServiceExtensionUri(uri);
} }
createTld("net"); createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_omitFeeExtensionOnLogin_v12() throws Exception { public void testFailure_omitFeeExtensionOnLogin_v12() throws Exception {
thrown.expect(UndeclaredServiceExtensionException.class);
for (String uri : FEE_EXTENSION_URIS) { for (String uri : FEE_EXTENSION_URIS) {
removeServiceExtensionUri(uri); removeServiceExtensionUri(uri);
} }
createTld("net"); createTld("net");
setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(UndeclaredServiceExtensionException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_feeGivenInWrongScale_v06() throws Exception { public void testFailure_feeGivenInWrongScale_v06() throws Exception {
thrown.expect(CurrencyValueScaleException.class);
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6")); setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11")); setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
persistContactsAndHosts(); persistContactsAndHosts();
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);
setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12")); setEppInput("domain_create_fee_bad_scale.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(CurrencyValueScaleException.class);
runFlow(); runFlow();
} }
private void doFailingDomainNameTest( private void doFailingDomainNameTest(
String domainName, String domainName,
Class<? extends Throwable> exception) throws Exception { Class<? extends Throwable> exception) throws Exception {
thrown.expect(exception);
setEppInput("domain_create_uppercase.xml"); setEppInput("domain_create_uppercase.xml");
eppLoader.replaceAll("Example.tld", domainName); eppLoader.replaceAll("Example.tld", domainName);
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(exception);
runFlow(); runFlow();
} }
@ -1341,10 +1344,10 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_sunriseRegistration() throws Exception { public void testFailure_sunriseRegistration() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.SUNRISE); createTld("tld", TldState.SUNRISE);
setEppInput("domain_create_registration_sunrise.xml"); setEppInput("domain_create_registration_sunrise.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@ -1393,16 +1396,15 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_sunrushRegistration() throws Exception { public void testFailure_sunrushRegistration() throws Exception {
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
createTld("tld", TldState.SUNRUSH); createTld("tld", TldState.SUNRUSH);
setEppInput("domain_create_registration_sunrush.xml"); setEppInput("domain_create_registration_sunrush.xml");
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NoGeneralRegistrationsInCurrentPhaseException.class);
runFlow(); runFlow();
} }
@Test @Test
public void testFailure_notAuthorizedForTld() throws Exception { public void testFailure_notAuthorizedForTld() throws Exception {
thrown.expect(NotAuthorizedForTldException.class);
createTld("irrelevant", "IRR"); createTld("irrelevant", "IRR");
DatastoreHelper.persistResource( DatastoreHelper.persistResource(
Registrar.loadByClientId("TheRegistrar") Registrar.loadByClientId("TheRegistrar")
@ -1410,6 +1412,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.setAllowedTlds(ImmutableSet.<String>of("irrelevant")) .setAllowedTlds(ImmutableSet.<String>of("irrelevant"))
.build()); .build());
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(NotAuthorizedForTldException.class);
runFlow(); runFlow();
} }
@ -1486,12 +1489,12 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_qlpLandrushRegistrationWithEncodedSignedMark() throws Exception { public void testFailure_qlpLandrushRegistrationWithEncodedSignedMark() throws Exception {
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
createTld("tld", TldState.LANDRUSH); createTld("tld", TldState.LANDRUSH);
clock.setTo(DateTime.parse("2014-09-09T09:09:09Z")); clock.setTo(DateTime.parse("2014-09-09T09:09:09Z"));
setEppInput("domain_create_registration_qlp_landrush_encoded_signed_mark.xml"); setEppInput("domain_create_registration_qlp_landrush_encoded_signed_mark.xml");
eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata. eppRequestSource = EppRequestSource.TOOL; // Only tools can pass in metadata.
persistContactsAndHosts(); persistContactsAndHosts();
thrown.expect(SignedMarksNotAcceptedInCurrentPhaseException.class);
runFlow(); runFlow();
} }

View file

@ -299,13 +299,13 @@ public class MutatingCommandTest {
@Test @Test
public void testFailure_nullEntityChange() throws Exception { public void testFailure_nullEntityChange() throws Exception {
thrown.expect(IllegalArgumentException.class);
MutatingCommand command = new MutatingCommand() { MutatingCommand command = new MutatingCommand() {
@Override @Override
protected void init() { protected void init() {
stageEntityChange(null, null); stageEntityChange(null, null);
} }
}; };
thrown.expect(IllegalArgumentException.class);
command.init(); command.init();
} }

View file

@ -257,7 +257,6 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
@Test @Test
public void testFailure_invalidPremiumList() throws Exception { public void testFailure_invalidPremiumList() throws Exception {
thrown.expect(IllegalArgumentException.class); thrown.expect(IllegalArgumentException.class);
runCommandForced( runCommandForced(
"--ip_whitelist=1.1.1.1", "--ip_whitelist=1.1.1.1",
"--registrar=blobio", "--registrar=blobio",
@ -269,7 +268,6 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
public void testFailure_tldExists() throws Exception { public void testFailure_tldExists() throws Exception {
createTld("blobio-sunrise"); createTld("blobio-sunrise");
thrown.expect(IllegalStateException.class); thrown.expect(IllegalStateException.class);
runCommandForced( runCommandForced(
"--ip_whitelist=1.1.1.1", "--ip_whitelist=1.1.1.1",
"--registrar=blobio", "--registrar=blobio",
@ -284,7 +282,6 @@ public class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
.build(); .build();
persistResource(registrar); persistResource(registrar);
thrown.expect(IllegalStateException.class); thrown.expect(IllegalStateException.class);
runCommandForced( runCommandForced(
"--ip_whitelist=1.1.1.1", "--ip_whitelist=1.1.1.1",
"--registrar=blobio", "--registrar=blobio",