mirror of
https://github.com/google/nomulus.git
synced 2025-07-22 18:55:58 +02:00
Remove old DomainList fields from Registry (#1231)
* Remove old DomainList fields from Registry I also resaved all Registry objects in sandbox and production to make sure that the new field is populated on all entity objects. * small fixes * Some more small fixes * Delete commented out code * Remove existence check in tests
This commit is contained in:
parent
f5d344d5c9
commit
d283cf1c90
17 changed files with 79 additions and 152 deletions
|
@ -113,7 +113,7 @@ public class ExportPremiumTermsAction implements Runnable {
|
|||
"Skipping premium terms export for TLD %s because Drive folder isn't specified", tld);
|
||||
return Optional.of("Skipping export because no Drive folder is associated with this TLD");
|
||||
}
|
||||
if (!registry.getPremiumList().isPresent()) {
|
||||
if (!registry.getPremiumListName().isPresent()) {
|
||||
logger.atInfo().log("No premium terms to export for TLD %s", tld);
|
||||
return Optional.of("No premium lists configured");
|
||||
}
|
||||
|
@ -137,8 +137,8 @@ public class ExportPremiumTermsAction implements Runnable {
|
|||
}
|
||||
|
||||
private String getFormattedPremiumTerms(Registry registry) {
|
||||
checkState(registry.getPremiumList().isPresent(), "%s does not have a premium list", tld);
|
||||
String premiumListName = registry.getPremiumList().get().getName();
|
||||
checkState(registry.getPremiumListName().isPresent(), "%s does not have a premium list", tld);
|
||||
String premiumListName = registry.getPremiumListName().get();
|
||||
checkState(
|
||||
PremiumListDao.getLatestRevision(premiumListName).isPresent(),
|
||||
"Could not load premium list for " + tld);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ExportReservedTermsAction implements Runnable {
|
|||
try {
|
||||
Registry registry = Registry.get(tld);
|
||||
String resultMsg;
|
||||
if (registry.getReservedLists().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) {
|
||||
if (registry.getReservedListNames().isEmpty() && isNullOrEmpty(registry.getDriveFolderId())) {
|
||||
resultMsg = "No reserved lists configured";
|
||||
logger.atInfo().log("No reserved terms to export for TLD %s", tld);
|
||||
} else if (registry.getDriveFolderId() == null) {
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
package google.registry.export;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.ReservedList;
|
||||
import google.registry.model.registry.label.ReservedList.ReservedListEntry;
|
||||
import google.registry.model.registry.label.ReservedListDao;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import javax.inject.Inject;
|
||||
|
@ -39,8 +39,13 @@ public final class ExportUtils {
|
|||
public String exportReservedTerms(Registry registry) {
|
||||
StringBuilder termsBuilder = new StringBuilder(reservedTermsExportDisclaimer).append("\n");
|
||||
Set<String> reservedTerms = new TreeSet<>();
|
||||
for (Key<ReservedList> key : registry.getReservedLists()) {
|
||||
ReservedList reservedList = ReservedList.load(key).get();
|
||||
for (String reservedListName : registry.getReservedListNames()) {
|
||||
ReservedList reservedList =
|
||||
ReservedListDao.getLatestRevision(reservedListName)
|
||||
.orElseThrow(
|
||||
() ->
|
||||
new IllegalStateException(
|
||||
String.format("Reserved list %s does not exist", reservedListName)));
|
||||
if (reservedList.getShouldPublish()) {
|
||||
for (ReservedListEntry entry : reservedList.getReservedListEntries().values()) {
|
||||
reservedTerms.add(entry.getLabel());
|
||||
|
|
|
@ -39,9 +39,7 @@ public final class StaticPremiumListPricingEngine implements PremiumPricingEngin
|
|||
String label = InternetDomainName.from(fullyQualifiedDomainName).parts().get(0);
|
||||
Registry registry = Registry.get(checkNotNull(tld, "tld"));
|
||||
Optional<Money> premiumPrice =
|
||||
registry
|
||||
.getPremiumList()
|
||||
.flatMap(listKey -> PremiumListDao.getPremiumPrice(listKey.getName(), label));
|
||||
registry.getPremiumListName().flatMap(pl -> PremiumListDao.getPremiumPrice(pl, label));
|
||||
return DomainPrices.create(
|
||||
premiumPrice.isPresent(),
|
||||
premiumPrice.orElse(registry.getStandardCreateCost()),
|
||||
|
|
|
@ -47,7 +47,6 @@ import com.googlecode.objectify.annotation.Embed;
|
|||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Mapify;
|
||||
import com.googlecode.objectify.annotation.OnLoad;
|
||||
import com.googlecode.objectify.annotation.OnSave;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import google.registry.model.Buildable;
|
||||
|
@ -112,26 +111,6 @@ public class Registry extends ImmutableObject implements Buildable, DatastoreAnd
|
|||
@PostLoad
|
||||
void postLoad() {
|
||||
tldStr = tldStrId;
|
||||
// TODO(sarahbot@): Remove the rest of this method after this data migration is complete
|
||||
if (premiumListName != null) {
|
||||
premiumList = Key.create(getCrossTldKey(), PremiumList.class, premiumListName);
|
||||
}
|
||||
if (reservedListNames != null) {
|
||||
reservedLists =
|
||||
reservedListNames.stream()
|
||||
.map(name -> Key.create(getCrossTldKey(), ReservedList.class, name))
|
||||
.collect(toImmutableSet());
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(sarahbot@): Remove this method after this data migration is complete
|
||||
@OnLoad
|
||||
void onLoad() {
|
||||
if (reservedLists != null) {
|
||||
reservedListNames =
|
||||
reservedLists.stream().map(key -> key.getName()).collect(toImmutableSet());
|
||||
}
|
||||
premiumListName = premiumList == null ? null : premiumList.getName();
|
||||
}
|
||||
|
||||
/** The suffix that identifies roids as belonging to this specific tld, e.g. -HOW for .how. */
|
||||
|
@ -408,9 +387,6 @@ public class Registry extends ImmutableObject implements Buildable, DatastoreAnd
|
|||
@Column(nullable = false)
|
||||
CreateAutoTimestamp creationTime = CreateAutoTimestamp.create(null);
|
||||
|
||||
/** The set of reserved lists that are applicable to this registry. */
|
||||
@Transient Set<Key<ReservedList>> reservedLists;
|
||||
|
||||
/** The set of reserved list names that are applicable to this registry. */
|
||||
@Column(name = "reserved_list_names")
|
||||
Set<String> reservedListNames;
|
||||
|
@ -423,13 +399,10 @@ public class Registry extends ImmutableObject implements Buildable, DatastoreAnd
|
|||
* for a registry, the database should be queried for the entity with this name that has the
|
||||
* largest revision ID.
|
||||
*/
|
||||
public ImmutableSet<Key<ReservedList>> getReservedLists() {
|
||||
return nullToEmptyImmutableCopy(reservedLists);
|
||||
public ImmutableSet<String> getReservedListNames() {
|
||||
return nullToEmptyImmutableCopy(reservedListNames);
|
||||
}
|
||||
|
||||
/** The static {@link PremiumList} for this TLD, if there is one. */
|
||||
@Transient Key<PremiumList> premiumList;
|
||||
|
||||
/**
|
||||
* The name of the {@link PremiumList} for this TLD, if there is one.
|
||||
*
|
||||
|
@ -647,8 +620,8 @@ public class Registry extends ImmutableObject implements Buildable, DatastoreAnd
|
|||
return anchorTenantAddGracePeriodLength;
|
||||
}
|
||||
|
||||
public Optional<Key<PremiumList>> getPremiumList() {
|
||||
return Optional.ofNullable(premiumList);
|
||||
public Optional<String> getPremiumListName() {
|
||||
return Optional.ofNullable(premiumListName);
|
||||
}
|
||||
|
||||
public CurrencyUnit getCurrency() {
|
||||
|
@ -919,26 +892,15 @@ public class Registry extends ImmutableObject implements Buildable, DatastoreAnd
|
|||
|
||||
public Builder setReservedLists(Set<ReservedList> reservedLists) {
|
||||
checkArgumentNotNull(reservedLists, "reservedLists must not be null");
|
||||
ImmutableSet.Builder<Key<ReservedList>> builder = new ImmutableSet.Builder<>();
|
||||
ImmutableSet.Builder<String> nameBuilder = new ImmutableSet.Builder<>();
|
||||
for (ReservedList reservedList : reservedLists) {
|
||||
builder.add(Key.create(reservedList));
|
||||
nameBuilder.add(reservedList.getName());
|
||||
}
|
||||
getInstance().reservedLists = builder.build();
|
||||
getInstance().reservedListNames = nameBuilder.build();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPremiumList(@Nullable PremiumList premiumList) {
|
||||
getInstance().premiumList = (premiumList == null) ? null : Key.create(premiumList);
|
||||
getInstance().premiumListName = (premiumList == null) ? null : premiumList.getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public Builder setPremiumListKey(@Nullable Key<PremiumList> premiumList) {
|
||||
getInstance().premiumList = premiumList;
|
||||
getInstance().premiumListName = (premiumList == null) ? null : premiumList.getName();
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ public abstract class BaseDomainLabelList<T extends Comparable<?>, R extends Dom
|
|||
.collect(toImmutableSet());
|
||||
}
|
||||
|
||||
// TODO(b/193043636): Refactor this class to no longer use key references
|
||||
protected abstract boolean refersToKey(
|
||||
Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key);
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ public final class PremiumList extends BaseDomainLabelList<Money, PremiumList.Pr
|
|||
|
||||
@Override
|
||||
public boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
return Objects.equals(registry.getPremiumList().orElse(null), key);
|
||||
return Objects.equals(registry.getPremiumListName().orElse(null), key.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,7 +20,6 @@ import static com.google.common.base.Strings.isNullOrEmpty;
|
|||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static google.registry.config.RegistryConfig.getDomainLabelListCacheDuration;
|
||||
import static google.registry.model.ImmutableObject.Insignificant;
|
||||
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
|
||||
import static google.registry.persistence.transaction.QueryComposer.Comparator.EQ;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
|
@ -187,7 +186,7 @@ public final class ReservedList
|
|||
|
||||
@Override
|
||||
protected boolean refersToKey(Registry registry, Key<? extends BaseDomainLabelList<?, ?>> key) {
|
||||
return registry.getReservedLists().contains(key);
|
||||
return registry.getReservedListNames().contains(key.getName());
|
||||
}
|
||||
|
||||
/** Determines whether the ReservedList is in use on any Registry */
|
||||
|
@ -236,11 +235,6 @@ public final class ReservedList
|
|||
return getFromCache(listName, cache);
|
||||
}
|
||||
|
||||
/** Loads a ReservedList from its Objectify key. */
|
||||
public static Optional<ReservedList> load(Key<ReservedList> key) {
|
||||
return get(key.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the set of all reserved lists associated with the specified TLD and returns the
|
||||
* reservation types of the label.
|
||||
|
@ -270,7 +264,7 @@ public final class ReservedList
|
|||
new ImmutableSet.Builder<>();
|
||||
|
||||
// Loop through all reservation lists and add each of them.
|
||||
for (ReservedList rl : loadReservedLists(registry.getReservedLists())) {
|
||||
for (ReservedList rl : loadReservedLists(registry.getReservedListNames())) {
|
||||
if (rl.getReservedListEntries().containsKey(label)) {
|
||||
ReservedListEntry entry = rl.getReservedListEntries().get(label);
|
||||
entriesBuilder.add(entry);
|
||||
|
@ -285,17 +279,15 @@ public final class ReservedList
|
|||
}
|
||||
|
||||
private static ImmutableSet<ReservedList> loadReservedLists(
|
||||
ImmutableSet<Key<ReservedList>> reservedListKeys) {
|
||||
return reservedListKeys
|
||||
.stream()
|
||||
ImmutableSet<String> reservedListNames) {
|
||||
return reservedListNames.stream()
|
||||
.map(
|
||||
(listKey) -> {
|
||||
(listName) -> {
|
||||
try {
|
||||
return cache.get(listKey.getName());
|
||||
return cache.get(listName);
|
||||
} catch (ExecutionException e) {
|
||||
throw new UncheckedExecutionException(
|
||||
String.format(
|
||||
"Could not load the reserved list '%s' from the cache", listKey.getName()),
|
||||
String.format("Could not load the reserved list '%s' from the cache", listName),
|
||||
e);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
package google.registry.tools;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
|
@ -26,7 +25,6 @@ import com.beust.jcommander.Parameter;
|
|||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.config.RegistryEnvironment;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.Registry.TldState;
|
||||
|
@ -113,7 +111,7 @@ class UpdateTldCommand extends CreateOrUpdateTldCommand {
|
|||
ImmutableSet<String> getReservedLists(Registry oldRegistry) {
|
||||
return formUpdatedList(
|
||||
"reserved lists",
|
||||
oldRegistry.getReservedLists().stream().map(Key::getName).collect(toImmutableSet()),
|
||||
oldRegistry.getReservedListNames(),
|
||||
reservedListNames,
|
||||
reservedListsAdd,
|
||||
reservedListsRemove);
|
||||
|
|
|
@ -70,8 +70,7 @@ public final class OteAccountBuilderTest {
|
|||
private void assertTldExists(String tld, TldState tldState, Money eapFee) {
|
||||
Registry registry = Registry.get(tld);
|
||||
assertThat(registry).isNotNull();
|
||||
assertThat(registry.getPremiumList()).isPresent();
|
||||
assertThat(registry.getPremiumList().get().getName()).isEqualTo("default_sandbox_list");
|
||||
assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list");
|
||||
assertThat(registry.getTldStateTransitions()).containsExactly(START_OF_TIME, tldState);
|
||||
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
|
||||
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardHours(1));
|
||||
|
|
|
@ -36,7 +36,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.dns.writer.VoidDnsWriter;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.registry.Registry.RegistryNotFoundException;
|
||||
|
@ -162,18 +161,18 @@ public final class RegistryTest extends EntityTestCase {
|
|||
.asBuilder()
|
||||
.setReservedLists(ImmutableSet.of(rl15))
|
||||
.build();
|
||||
assertThat(registry1.getReservedLists()).hasSize(1);
|
||||
assertThat(registry1.getReservedListNames()).hasSize(1);
|
||||
Registry registry2 =
|
||||
registry1.asBuilder().setReservedLists(ImmutableSet.of(rl15, rl16)).build();
|
||||
assertThat(registry1.getReservedLists()).hasSize(1);
|
||||
assertThat(registry2.getReservedLists()).hasSize(2);
|
||||
assertThat(registry1.getReservedListNames()).hasSize(1);
|
||||
assertThat(registry2.getReservedListNames()).hasSize(2);
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testGetReservedLists_doesntReturnNullWhenUninitialized() {
|
||||
Registry registry = newRegistry("foo", "FOO");
|
||||
assertThat(registry.getReservedLists()).isNotNull();
|
||||
assertThat(registry.getReservedLists()).isEmpty();
|
||||
assertThat(registry.getReservedListNames()).isNotNull();
|
||||
assertThat(registry.getReservedListNames()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
|
@ -211,10 +210,9 @@ public final class RegistryTest extends EntityTestCase {
|
|||
.build());
|
||||
Registry r =
|
||||
Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of(rl5, rl6)).build();
|
||||
assertThat(r.getReservedLists().stream().map(Key::getName))
|
||||
.containsExactly("tld-reserved5", "tld-reserved6");
|
||||
assertThat(r.getReservedListNames()).containsExactly("tld-reserved5", "tld-reserved6");
|
||||
r = Registry.get("tld").asBuilder().setReservedLists(ImmutableSet.of()).build();
|
||||
assertThat(r.getReservedLists()).isEmpty();
|
||||
assertThat(r.getReservedListNames()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
|
@ -240,19 +238,18 @@ public final class RegistryTest extends EntityTestCase {
|
|||
.asBuilder()
|
||||
.setReservedListsByName(ImmutableSet.of("tld-reserved15", "tld-reserved16"))
|
||||
.build();
|
||||
assertThat(r.getReservedLists().stream().map(Key::getName))
|
||||
.containsExactly("tld-reserved15", "tld-reserved16");
|
||||
assertThat(r.getReservedListNames()).containsExactly("tld-reserved15", "tld-reserved16");
|
||||
r = Registry.get("tld").asBuilder().setReservedListsByName(ImmutableSet.of()).build();
|
||||
assertThat(r.getReservedLists()).isEmpty();
|
||||
assertThat(r.getReservedListNames()).isEmpty();
|
||||
}
|
||||
|
||||
@TestOfyAndSql
|
||||
void testSetPremiumList() {
|
||||
PremiumList pl2 = persistPremiumList("tld2", "lol,USD 50", "cat,USD 700");
|
||||
Registry registry = Registry.get("tld").asBuilder().setPremiumList(pl2).build();
|
||||
Optional<Key<PremiumList>> plKey = registry.getPremiumList();
|
||||
assertThat(plKey).isPresent();
|
||||
PremiumList stored = PremiumListDao.getLatestRevision(plKey.get().getName()).get();
|
||||
Optional<String> pl = registry.getPremiumListName();
|
||||
assertThat(pl).hasValue("tld2");
|
||||
PremiumList stored = PremiumListDao.getLatestRevision(pl.get()).get();
|
||||
assertThat(stored.getName()).isEqualTo("tld2");
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class ReservedListTest {
|
|||
|
||||
@Test
|
||||
void testGetReservationTypes_allLabelsAreUnreserved_withNoReservedLists() {
|
||||
assertThat(Registry.get("tld").getReservedLists()).isEmpty();
|
||||
assertThat(Registry.get("tld").getReservedListNames()).isEmpty();
|
||||
assertThat(getReservationTypes("doodle", "tld")).isEmpty();
|
||||
assertThat(getReservationTypes("access", "tld")).isEmpty();
|
||||
assertThat(getReservationTypes("rich", "tld")).isEmpty();
|
||||
|
|
|
@ -16,7 +16,6 @@ package google.registry.schema.tld;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
import static google.registry.persistence.transaction.TransactionManagerUtil.transactIfJpaTm;
|
||||
import static google.registry.testing.DatabaseHelper.newRegistry;
|
||||
|
@ -27,7 +26,6 @@ import static org.joda.time.Duration.standardDays;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
|
@ -203,15 +201,7 @@ public class PremiumListDaoTest {
|
|||
|
||||
@Test
|
||||
void getPremiumPrice_worksSuccessfully() {
|
||||
persistResource(
|
||||
newRegistry("foobar", "FOOBAR")
|
||||
.asBuilder()
|
||||
.setPremiumListKey(
|
||||
Key.create(
|
||||
getCrossTldKey(),
|
||||
google.registry.model.registry.label.PremiumList.class,
|
||||
"premlist"))
|
||||
.build());
|
||||
PremiumList premiumList =
|
||||
PremiumListDao.save(
|
||||
new PremiumList.Builder()
|
||||
.setName("premlist")
|
||||
|
@ -219,6 +209,8 @@ public class PremiumListDaoTest {
|
|||
.setLabelsToPrices(TEST_PRICES)
|
||||
.setCreationTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
persistResource(
|
||||
newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build());
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(Money.of(USD, 10.23));
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(Money.of(USD, 1305.47));
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "zirconium")).isEmpty();
|
||||
|
@ -226,15 +218,7 @@ public class PremiumListDaoTest {
|
|||
|
||||
@Test
|
||||
void testGetPremiumPrice_worksForJPY() {
|
||||
persistResource(
|
||||
newRegistry("foobar", "FOOBAR")
|
||||
.asBuilder()
|
||||
.setPremiumListKey(
|
||||
Key.create(
|
||||
getCrossTldKey(),
|
||||
google.registry.model.registry.label.PremiumList.class,
|
||||
"premlist"))
|
||||
.build());
|
||||
PremiumList premiumList =
|
||||
PremiumListDao.save(
|
||||
new PremiumList.Builder()
|
||||
.setName("premlist")
|
||||
|
@ -249,6 +233,8 @@ public class PremiumListDaoTest {
|
|||
BigDecimal.valueOf(15000)))
|
||||
.setCreationTime(fakeClock.nowUtc())
|
||||
.build());
|
||||
persistResource(
|
||||
newRegistry("foobar", "FOOBAR").asBuilder().setPremiumList(premiumList).build());
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "silver")).hasValue(moneyOf(JPY, 10));
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "gold")).hasValue(moneyOf(JPY, 1000));
|
||||
assertThat(PremiumListDao.getPremiumPrice("premlist", "palladium"))
|
||||
|
|
|
@ -32,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Range;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.registry.Registry;
|
||||
import java.math.BigDecimal;
|
||||
import org.joda.money.Money;
|
||||
|
@ -279,7 +278,7 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=VoidDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
|
||||
.containsExactly("xn--q9jyb4c_abuse", "common_abuse");
|
||||
}
|
||||
|
||||
|
@ -519,9 +518,7 @@ class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
"--roid_suffix=Q9JYB4C",
|
||||
"--dns_writers=FooDnsWriter",
|
||||
"xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isPresent();
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().get().getName())
|
||||
.isEqualTo("xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -72,8 +72,7 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
|||
assertThat(registry.getRoidSuffix()).isEqualTo(roidSuffix);
|
||||
assertThat(registry.getTldState(DateTime.now(UTC))).isEqualTo(tldState);
|
||||
assertThat(registry.getDnsWriters()).containsExactly("VoidDnsWriter");
|
||||
assertThat(registry.getPremiumList()).isNotNull();
|
||||
assertThat(registry.getPremiumList().get().getName()).isEqualTo("default_sandbox_list");
|
||||
assertThat(registry.getPremiumListName()).hasValue("default_sandbox_list");
|
||||
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Duration.standardMinutes(60));
|
||||
assertThat(registry.getRedemptionGracePeriodLength()).isEqualTo(Duration.standardMinutes(10));
|
||||
assertThat(registry.getPendingDeleteLength()).isEqualTo(Duration.standardMinutes(5));
|
||||
|
|
|
@ -35,9 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
|||
import com.beust.jcommander.ParameterException;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.registry.Registry;
|
||||
import google.registry.model.registry.label.PremiumList;
|
||||
import java.util.Optional;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -254,7 +252,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
void testSuccess_setReservedLists() throws Exception {
|
||||
runCommandForced("--reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
|
||||
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
|
||||
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
|
||||
}
|
||||
|
||||
|
@ -264,7 +262,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
runCommandForced("--reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
|
||||
.containsExactly("xn--q9jyb4c_r2");
|
||||
}
|
||||
|
||||
|
@ -274,7 +272,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1"))
|
||||
.build());
|
||||
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r2", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
|
||||
.containsExactly("xn--q9jyb4c_r1", "xn--q9jyb4c_r2");
|
||||
}
|
||||
|
||||
|
@ -284,7 +282,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists()).isEmpty();
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -293,7 +291,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
.setReservedListsByName(ImmutableSet.of("xn--q9jyb4c_r1", "xn--q9jyb4c_r2"))
|
||||
.build());
|
||||
runCommandForced("--remove_reserved_lists=xn--q9jyb4c_r1", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedLists().stream().map(Key::getName))
|
||||
assertThat(Registry.get("xn--q9jyb4c").getReservedListNames())
|
||||
.containsExactly("xn--q9jyb4c_r2");
|
||||
}
|
||||
|
||||
|
@ -839,21 +837,20 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
@Test
|
||||
void testSuccess_removePremiumListWithNull() throws Exception {
|
||||
runCommandForced("--premium_list=null", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isEmpty();
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_removePremiumListWithBlank() throws Exception {
|
||||
runCommandForced("--premium_list=", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isEmpty();
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_premiumListNotRemovedWhenNotSpecified() throws Exception {
|
||||
runCommandForced("--add_reserved_lists=xn--q9jyb4c_r1,xn--q9jyb4c_r2", "xn--q9jyb4c");
|
||||
Optional<Key<PremiumList>> premiumListKey = Registry.get("xn--q9jyb4c").getPremiumList();
|
||||
assertThat(premiumListKey).isPresent();
|
||||
assertThat(premiumListKey.get().getName()).isEqualTo("xn--q9jyb4c");
|
||||
Optional<String> premiumListName = Registry.get("xn--q9jyb4c").getPremiumListName();
|
||||
assertThat(premiumListName).hasValue("xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -921,9 +918,7 @@ class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
|
|||
@Test
|
||||
void testSuccess_setPremiumList() throws Exception {
|
||||
runCommandForced("--premium_list=xn--q9jyb4c", "xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList()).isPresent();
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumList().get().getName())
|
||||
.isEqualTo("xn--q9jyb4c");
|
||||
assertThat(Registry.get("xn--q9jyb4c").getPremiumListName()).hasValue("xn--q9jyb4c");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -658,7 +658,6 @@ class google.registry.model.registry.Registry {
|
|||
boolean dnsPaused;
|
||||
boolean escrowEnabled;
|
||||
boolean invoicingEnabled;
|
||||
com.googlecode.objectify.Key<google.registry.model.registry.label.PremiumList> premiumList;
|
||||
google.registry.model.CreateAutoTimestamp creationTime;
|
||||
google.registry.model.common.TimedTransitionProperty<google.registry.model.registry.Registry$TldState, google.registry.model.registry.Registry$TldStateTransition> tldStateTransitions;
|
||||
google.registry.model.common.TimedTransitionProperty<org.joda.money.Money, google.registry.model.registry.Registry$BillingCostTransition> eapFeeSchedule;
|
||||
|
@ -672,7 +671,6 @@ class google.registry.model.registry.Registry {
|
|||
java.lang.String roidSuffix;
|
||||
java.lang.String tldStr;
|
||||
java.lang.String tldUnicode;
|
||||
java.util.Set<com.googlecode.objectify.Key<google.registry.model.registry.label.ReservedList>> reservedLists;
|
||||
java.util.Set<java.lang.String> allowedFullyQualifiedHostNames;
|
||||
java.util.Set<java.lang.String> allowedRegistrantContactIds;
|
||||
java.util.Set<java.lang.String> dnsWriters;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue