From d485c5d7e2e123337f5066b7bf066daf23337925 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 16 Dec 2016 13:42:50 -0800 Subject: [PATCH] Add a domain application update custom pricing logic test ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142294037 --- .../custom/TestDomainPricingCustomLogic.java | 20 ++++++++++++ .../DomainApplicationUpdateFlowTest.java | 8 +++-- .../testdata/domain_update_sunrise_fee.xml | 31 +++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 javatests/google/registry/flows/domain/testdata/domain_update_sunrise_fee.xml diff --git a/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java b/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java index c1bb37d46..c1fe704ec 100644 --- a/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java +++ b/javatests/google/registry/flows/custom/TestDomainPricingCustomLogic.java @@ -82,6 +82,26 @@ public class TestDomainPricingCustomLogic extends DomainPricingCustomLogic { } } + @Override + public FeesAndCredits customizeApplicationUpdatePrice( + ApplicationUpdatePriceParameters priceParameters) throws EppException { + if (priceParameters + .domainApplication() + .getFullyQualifiedDomainName() + .startsWith("non-free-update")) { + FeesAndCredits feesAndCredits = priceParameters.feesAndCredits(); + List newFeesAndCredits = + new ImmutableList.Builder() + .addAll(feesAndCredits.getFeesAndCredits()) + .add(Fee.create(BigDecimal.valueOf(100), FeeType.UPDATE)) + .build(); + return new FeesAndCredits( + feesAndCredits.getCurrency(), toArray(newFeesAndCredits, BaseFee.class)); + } else { + return priceParameters.feesAndCredits(); + } + } + @Override public FeesAndCredits customizeRenewPrice(RenewPriceParameters priceParameters) throws EppException { diff --git a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java index e72861fea..e6af57cc6 100644 --- a/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java +++ b/javatests/google/registry/flows/domain/DomainApplicationUpdateFlowTest.java @@ -673,11 +673,13 @@ public class DomainApplicationUpdateFlowTest } @Test - public void testFailure_flags_feeMismatch() throws Exception { + public void testFailure_customPricingLogic_feeMismatch() throws Exception { persistReferencedEntities(); persistResource( - newDomainApplication("update-42.flags").asBuilder().setRepoId("1-ROID").build()); - setEppInput("domain_update_sunrise_flags.xml", ImmutableMap.of("FEE", "12")); + newDomainApplication("non-free-update.tld").asBuilder().setRepoId("1-ROID").build()); + setEppInput( + "domain_update_sunrise_fee.xml", + ImmutableMap.of("DOMAIN", "non-free-update.tld", "AMOUNT", "12")); clock.advanceOneMilli(); thrown.expect(FeesMismatchException.class); runFlow(); diff --git a/javatests/google/registry/flows/domain/testdata/domain_update_sunrise_fee.xml b/javatests/google/registry/flows/domain/testdata/domain_update_sunrise_fee.xml new file mode 100644 index 000000000..2e863ec72 --- /dev/null +++ b/javatests/google/registry/flows/domain/testdata/domain_update_sunrise_fee.xml @@ -0,0 +1,31 @@ + + + + + %DOMAIN% + + + ns2.example.tld + + + + + ns1.example.tld + + + + + + + sunrise + 1-ROID + + + USD + %AMOUNT% + + + ABC-12345 + +