mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Delete SetClockExtension (#1738)
We no longer write to commit logs, and the ReplayExtension that this extension is supposed to be used with is already deleted.
This commit is contained in:
parent
999f7d3cae
commit
2f9a45c91f
6 changed files with 16 additions and 98 deletions
|
@ -82,29 +82,21 @@ import google.registry.model.tld.Registry;
|
|||
import google.registry.model.tld.Registry.TldState;
|
||||
import google.registry.model.tld.label.ReservedList;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import java.math.BigDecimal;
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainCheckFlow}. */
|
||||
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Domain> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@RegisterExtension
|
||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2009-01-01T10:00:00Z");
|
||||
|
||||
DomainCheckFlowTest() {
|
||||
setEppInput("domain_check_one_tld.xml");
|
||||
clock.setTo(DateTime.parse("2009-01-01T10:00:00Z"));
|
||||
}
|
||||
|
||||
private ReservedList createReservedList() {
|
||||
private static ReservedList createReservedList() {
|
||||
persistResource(
|
||||
new AllocationToken.Builder()
|
||||
.setDomainName("anchor.tld")
|
||||
|
@ -951,10 +943,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
|||
// This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
|
||||
// display the number of digits that is conventional for the given currency.
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
.asBuilder()
|
||||
.setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1))
|
||||
.build());
|
||||
Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 11.1)).build());
|
||||
setEppInput("domain_check_fee_fractional.xml");
|
||||
runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml"));
|
||||
}
|
||||
|
@ -1398,7 +1387,6 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
|
|||
"domain_check_fee_date_v12.xml", "domain_check_eap_fee_response_date_v12.xml");
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void testSuccess_feeCheck_multipleRanges() {
|
||||
// TODO: If at some point we have more than one type of fees that are time dependent, populate
|
||||
|
|
|
@ -48,9 +48,9 @@ import google.registry.flows.domain.DomainFlowUtils.CurrencyUnitMismatchExceptio
|
|||
import google.registry.flows.domain.DomainFlowUtils.FeeChecksDontSupportPhasesException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.RestoresAreAlwaysForOneYearException;
|
||||
import google.registry.flows.domain.DomainFlowUtils.TransfersAreAlwaysForOneYearException;
|
||||
import google.registry.model.billing.BillingEvent;
|
||||
import google.registry.model.billing.BillingEvent.Flag;
|
||||
import google.registry.model.billing.BillingEvent.Reason;
|
||||
import google.registry.model.billing.BillingEvent.Recurring;
|
||||
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
|
||||
import google.registry.model.contact.ContactAuthInfo;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
|
@ -70,23 +70,16 @@ import google.registry.model.tld.Registry;
|
|||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainInfoFlow}. */
|
||||
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@RegisterExtension
|
||||
final SetClockExtension setClockExtension =
|
||||
new SetClockExtension(clock, "2005-03-03T22:00:00.000Z");
|
||||
|
||||
/**
|
||||
* The domain_info_fee.xml default substitutions common to most tests.
|
||||
*
|
||||
|
@ -99,6 +92,8 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
|||
"CURRENCY", "USD",
|
||||
"UNIT", "y");
|
||||
|
||||
private static final Pattern OK_PATTERN = Pattern.compile("\"ok\"");
|
||||
|
||||
private ContactResource registrant;
|
||||
private ContactResource contact;
|
||||
private Host host1;
|
||||
|
@ -109,6 +104,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
|||
@BeforeEach
|
||||
void setup() {
|
||||
setEppInput("domain_info.xml");
|
||||
clock.setTo(DateTime.parse("2005-03-03T22:00:00.000Z"));
|
||||
sessionMetadata.setRegistrarId("NewRegistrar");
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
|
@ -175,7 +171,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
|||
String expected =
|
||||
loadFile(expectedXmlFilename, updateSubstitutions(substitutions, "ROID", "2FF-TLD"));
|
||||
if (inactive) {
|
||||
expected = expected.replaceAll("\"ok\"", "\"inactive\"");
|
||||
expected = OK_PATTERN.matcher(expected).replaceAll("\"inactive\"");
|
||||
}
|
||||
runFlowAssertResponse(expected);
|
||||
if (!expectHistoryAndBilling) {
|
||||
|
@ -379,9 +375,9 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
|||
.setModificationTime(clock.nowUtc())
|
||||
.setRegistrarId(domain.getCreationRegistrarId())
|
||||
.build());
|
||||
BillingEvent.Recurring renewEvent =
|
||||
Recurring renewEvent =
|
||||
persistResource(
|
||||
new BillingEvent.Recurring.Builder()
|
||||
new Recurring.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
|
@ -390,7 +386,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
|
|||
.setRecurrenceEndTime(END_OF_TIME)
|
||||
.setDomainHistory(historyEntry)
|
||||
.build());
|
||||
VKey<BillingEvent.Recurring> recurringVKey = renewEvent.createVKey();
|
||||
VKey<Recurring> recurringVKey = renewEvent.createVKey();
|
||||
// Add an AUTO_RENEW grace period to the saved resource.
|
||||
persistResource(
|
||||
domain
|
||||
|
|
|
@ -29,7 +29,6 @@ import static google.registry.testing.DatabaseHelper.createTld;
|
|||
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
|
||||
import static google.registry.testing.DatabaseHelper.loadByKey;
|
||||
import static google.registry.testing.DatabaseHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatabaseHelper.newDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
|
||||
import static google.registry.testing.DatabaseHelper.persistPremiumList;
|
||||
|
@ -95,16 +94,13 @@ import google.registry.model.reporting.HistoryEntry;
|
|||
import google.registry.model.tld.Registry;
|
||||
import google.registry.persistence.VKey;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link DomainRenewFlow}. */
|
||||
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain> {
|
||||
|
@ -126,13 +122,9 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain>
|
|||
|
||||
private final DateTime expirationTime = DateTime.parse("2000-04-03T22:00:00.0Z");
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@RegisterExtension
|
||||
final SetClockExtension setClockExtension =
|
||||
new SetClockExtension(clock, expirationTime.minusMillis(20));
|
||||
|
||||
@BeforeEach
|
||||
void initDomainTest() {
|
||||
clock.setTo(expirationTime.minusMillis(20));
|
||||
createTld("tld");
|
||||
persistResource(
|
||||
loadRegistrar("TheRegistrar")
|
||||
|
|
|
@ -32,20 +32,13 @@ import google.registry.model.contact.ContactResource;
|
|||
import google.registry.model.domain.Domain;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link PollAckFlow}. */
|
||||
class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@RegisterExtension
|
||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2011-01-02T01:01:01Z");
|
||||
|
||||
/** This is the message id being sent in the ACK request. */
|
||||
private static final long MESSAGE_ID = 3;
|
||||
|
||||
|
@ -55,6 +48,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
|
|||
@BeforeEach
|
||||
void setUp() {
|
||||
setEppInput("poll_ack.xml", ImmutableMap.of("MSGID", "1-3-EXAMPLE-4-3-2011"));
|
||||
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
createTld("example");
|
||||
contact = persistActiveContact("jd1234");
|
||||
|
|
|
@ -40,19 +40,13 @@ import google.registry.model.transfer.TransferResponse.ContactTransferResponse;
|
|||
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.testing.DatabaseHelper;
|
||||
import google.registry.testing.SetClockExtension;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
/** Unit tests for {@link PollRequestFlow}. */
|
||||
class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
||||
|
||||
@Order(value = Order.DEFAULT - 3)
|
||||
@RegisterExtension
|
||||
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2011-01-02T01:01:01Z");
|
||||
|
||||
private Domain domain;
|
||||
private ContactResource contact;
|
||||
private Host host;
|
||||
|
@ -60,6 +54,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
|
|||
@BeforeEach
|
||||
void setUp() {
|
||||
setEppInput("poll.xml");
|
||||
clock.setTo(DateTime.parse("2011-01-02T01:01:01Z"));
|
||||
setRegistrarIdForFlow("NewRegistrar");
|
||||
createTld("example");
|
||||
persistNewRegistrar("BadRegistrar");
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
// Copyright 2021 The Nomulus 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.testing;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
/**
|
||||
* Extension used for tests that a) set the clock to a specific time and b) make use of
|
||||
* ReplayExtension or any other test feature that requires writing to a commit log from test
|
||||
* utilities that aren't controlled by the ultimate test class (e.g. AppEngineExtension).
|
||||
*/
|
||||
public class SetClockExtension implements BeforeEachCallback {
|
||||
|
||||
private FakeClock clock;
|
||||
private DateTime dateTime;
|
||||
|
||||
/** Construct from a DateTime, that being the time to set the clock to. */
|
||||
public SetClockExtension(FakeClock clock, DateTime dateTime) {
|
||||
this.clock = clock;
|
||||
this.dateTime = dateTime;
|
||||
}
|
||||
|
||||
/** Construct from a dateTime (the time to set the clock to) represented as a string. */
|
||||
public SetClockExtension(FakeClock clock, String dateTime) {
|
||||
this.clock = clock;
|
||||
this.dateTime = DateTime.parse(dateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) {
|
||||
clock.setTo(dateTime);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue