mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Rename TldSpecificLogicEngine to TldSpecificLogicProxy
This new name is a more accurate description of what the actual class does. TldSpecificLogicEngine is an interface that will be added in the near future, implementations of which will provide custom per-TLD logic. The class being renamed is more properly a proxy that only handles logic generic to all TLDs. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127088913
This commit is contained in:
parent
b74ab4bc27
commit
cd23ece924
4 changed files with 119 additions and 12 deletions
|
@ -65,8 +65,8 @@ import google.registry.model.registry.Registry;
|
|||
import google.registry.model.registry.Registry.TldState;
|
||||
import google.registry.model.smd.SignedMark;
|
||||
import google.registry.model.tmch.ClaimsListShard;
|
||||
import google.registry.pricing.TldSpecificLogicEngine;
|
||||
import google.registry.pricing.TldSpecificLogicEngine.EppCommandOperations;
|
||||
import google.registry.pricing.TldSpecificLogicProxy;
|
||||
import google.registry.pricing.TldSpecificLogicProxy.EppCommandOperations;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -180,7 +180,7 @@ public abstract class BaseDomainCreateFlow<R extends DomainBase, B extends Build
|
|||
tldState = registry.getTldState(now);
|
||||
checkRegistryStateForTld(tld);
|
||||
domainLabel = domainName.parts().get(0);
|
||||
commandOperations = TldSpecificLogicEngine.getCreatePrice(
|
||||
commandOperations = TldSpecificLogicProxy.getCreatePrice(
|
||||
registry, domainName.toString(), now, command.getPeriod().getValue());
|
||||
// The TLD should always be the parent of the requested domain name.
|
||||
isAnchorTenantViaReservation = matchesAnchorTenantReservation(
|
||||
|
|
|
@ -88,7 +88,7 @@ import google.registry.model.smd.AbstractSignedMark;
|
|||
import google.registry.model.smd.EncodedSignedMark;
|
||||
import google.registry.model.smd.SignedMark;
|
||||
import google.registry.model.smd.SignedMarkRevocationList;
|
||||
import google.registry.pricing.TldSpecificLogicEngine;
|
||||
import google.registry.pricing.TldSpecificLogicProxy;
|
||||
import google.registry.tmch.TmchXmlSignature;
|
||||
import google.registry.tmch.TmchXmlSignature.CertificateSignatureException;
|
||||
import google.registry.util.Idn;
|
||||
|
@ -580,7 +580,7 @@ public class DomainFlowUtils {
|
|||
.setCommand(feeCommand)
|
||||
.setCurrency(registry.getCurrency())
|
||||
.setPeriod(feeRequest.getPeriod())
|
||||
.setClass(TldSpecificLogicEngine.getFeeClass(domainName, now).orNull());
|
||||
.setClass(TldSpecificLogicProxy.getFeeClass(domainName, now).orNull());
|
||||
|
||||
switch (feeCommand.getCommand()) {
|
||||
case UNKNOWN:
|
||||
|
@ -590,7 +590,7 @@ public class DomainFlowUtils {
|
|||
builder.setClass("reserved"); // Override whatever class we've set above.
|
||||
} else {
|
||||
builder.setFees(
|
||||
TldSpecificLogicEngine.getCreatePrice(registry, domainName, now, years).getFees());
|
||||
TldSpecificLogicProxy.getCreatePrice(registry, domainName, now, years).getFees());
|
||||
}
|
||||
break;
|
||||
case RESTORE:
|
||||
|
@ -598,12 +598,12 @@ public class DomainFlowUtils {
|
|||
throw new RestoresAreAlwaysForOneYearException();
|
||||
}
|
||||
builder.setFees(
|
||||
TldSpecificLogicEngine.getRestorePrice(registry, domainName, now, years).getFees());
|
||||
TldSpecificLogicProxy.getRestorePrice(registry, domainName, now, years).getFees());
|
||||
break;
|
||||
default:
|
||||
// Anything else (transfer|renew) will have a "renew" fee.
|
||||
builder.setFees(
|
||||
TldSpecificLogicEngine.getRenewPrice(registry, domainName, now, years).getFees());
|
||||
TldSpecificLogicProxy.getRenewPrice(registry, domainName, now, years).getFees());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@ import org.joda.money.Money;
|
|||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* Provides specialized pricing, billing and update logic per TLD. TODO: consider making these
|
||||
* methods of Registry.
|
||||
* Provides pricing, billing, and update logic, with call-outs that can be customized by providing
|
||||
* implementations on a per-TLD basis.
|
||||
*/
|
||||
public final class TldSpecificLogicEngine {
|
||||
public final class TldSpecificLogicProxy {
|
||||
|
||||
private static final String EAP_DESCRIPTION_FORMAT = "Early Access Period, fee expires: %s";
|
||||
|
||||
|
@ -80,7 +80,7 @@ public final class TldSpecificLogicEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private TldSpecificLogicEngine() {}
|
||||
private TldSpecificLogicProxy() {}
|
||||
|
||||
/**
|
||||
* Returns a new "create" price for the Pricer.
|
107
javatests/google/registry/pricing/TldSpecificLogicProxyTest.java
Normal file
107
javatests/google/registry/pricing/TldSpecificLogicProxyTest.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package google.registry.pricing;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
|
||||
import google.registry.model.domain.fee.Fee;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.testing.AppEngineRule;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectRule;
|
||||
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
@RunWith(JUnit4.class)
|
||||
public class TldSpecificLogicProxyTest {
|
||||
|
||||
@Rule
|
||||
public final InjectRule inject = new InjectRule();
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder().withDatastore().build();
|
||||
|
||||
final FakeClock clock = new FakeClock(DateTime.parse("2010-01-01T10:00:00Z"));
|
||||
|
||||
Money basicCreateCost;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
inject.setStaticField(Ofy.class, "clock", clock);
|
||||
createTld("tld");
|
||||
|
||||
createTld("eap");
|
||||
DateTime a = clock.nowUtc().minusDays(1);
|
||||
DateTime b = clock.nowUtc().plusDays(1);
|
||||
persistResource(
|
||||
Registry.get("eap")
|
||||
.asBuilder()
|
||||
.setEapFeeSchedule(
|
||||
ImmutableSortedMap.of(
|
||||
START_OF_TIME, Money.of(USD, 0),
|
||||
a, Money.of(USD, 100),
|
||||
b, Money.of(USD, 50)))
|
||||
.build());
|
||||
|
||||
basicCreateCost =
|
||||
PricingEngineProxy.getPricesForDomainName("example.tld", clock.nowUtc()).getCreateCost();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTldSpecificLogicEngine() {
|
||||
TldSpecificLogicProxy.EppCommandOperations createPrice =
|
||||
TldSpecificLogicProxy.getCreatePrice(
|
||||
Registry.get("tld"), "example.tld", clock.nowUtc(), 1);
|
||||
assertThat(createPrice.getTotalCost()).isEqualTo(basicCreateCost);
|
||||
assertThat(createPrice.getFees()).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTldSpecificLogicEngineEap() {
|
||||
TldSpecificLogicProxy.EppCommandOperations createPrice =
|
||||
TldSpecificLogicProxy.getCreatePrice(
|
||||
Registry.get("eap"), "example.eap", clock.nowUtc(), 1);
|
||||
assertThat(createPrice.getTotalCost()).isEqualTo(basicCreateCost.plus(Money.of(USD, 100)));
|
||||
assertThat(createPrice.getCurrency()).isEqualTo(USD);
|
||||
assertThat(createPrice.getFees().get(0))
|
||||
.isEqualTo(Fee.create(basicCreateCost.getAmount(), "create"));
|
||||
assertThat(createPrice.getFees().get(1))
|
||||
.isEqualTo(
|
||||
Fee.create(
|
||||
Money.of(USD, 100).getAmount(),
|
||||
"Early Access Period, fee expires: " + clock.nowUtc().plusDays(1)));
|
||||
assertThat(createPrice.getFees())
|
||||
.isEqualTo(
|
||||
ImmutableList.of(
|
||||
Fee.create(basicCreateCost.getAmount(), "create"),
|
||||
Fee.create(
|
||||
Money.of(USD, 100).getAmount(),
|
||||
"Early Access Period, fee expires: " + clock.nowUtc().plusDays(1))));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue