mirror of
https://github.com/google/nomulus
synced 2026-09-18 22:14:23 +00:00
Remove ReservedList from Datastore schema (#1285)
* Remove ReservedList from Datastore schema * Remove some Datastore references * Add a different non-replicated entity to ReplayCommitLogsToSqlActionTest
This commit is contained in:
@@ -38,7 +38,6 @@ import static org.mockito.Mockito.verify;
|
||||
|
||||
import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSortedMap;
|
||||
import com.google.common.truth.Truth8;
|
||||
@@ -55,12 +54,14 @@ import google.registry.model.index.ForeignKeyIndex;
|
||||
import google.registry.model.ofy.CommitLogBucket;
|
||||
import google.registry.model.ofy.CommitLogManifest;
|
||||
import google.registry.model.ofy.CommitLogMutation;
|
||||
import google.registry.model.rde.RdeMode;
|
||||
import google.registry.model.rde.RdeNamingUtils;
|
||||
import google.registry.model.rde.RdeRevision;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.replay.SqlReplayCheckpoint;
|
||||
import google.registry.model.server.Lock;
|
||||
import google.registry.model.tld.label.PremiumList;
|
||||
import google.registry.model.tld.label.PremiumList.PremiumEntry;
|
||||
import google.registry.model.tld.label.ReservedList;
|
||||
import google.registry.model.tmch.ClaimsList;
|
||||
import google.registry.model.translators.VKeyTranslatorFactory;
|
||||
import google.registry.persistence.VKey;
|
||||
@@ -419,8 +420,9 @@ public class ReplayCommitLogsToSqlActionTest {
|
||||
|
||||
createTld("tld");
|
||||
// Have a commit log with a couple objects that shouldn't be replayed
|
||||
ReservedList reservedList =
|
||||
new ReservedList.Builder().setReservedListMap(ImmutableMap.of()).setName("name").build();
|
||||
String triplet = RdeNamingUtils.makePartialName("tld", fakeClock.nowUtc(), RdeMode.FULL);
|
||||
RdeRevision rdeRevision =
|
||||
RdeRevision.create(triplet, "tld", fakeClock.nowUtc().toLocalDate(), RdeMode.FULL, 1);
|
||||
ForeignKeyIndex<DomainBase> fki = ForeignKeyIndex.create(newDomainBase("foo.tld"), now);
|
||||
tm().transact(
|
||||
() -> {
|
||||
@@ -430,8 +432,8 @@ public class ReplayCommitLogsToSqlActionTest {
|
||||
createCheckpoint(now.minusMinutes(1)),
|
||||
CommitLogManifest.create(
|
||||
getBucketKey(1), now.minusMinutes(1), ImmutableSet.of()),
|
||||
// Reserved list is dually-written non-replicated
|
||||
CommitLogMutation.create(manifestKey, reservedList),
|
||||
// RDE Revisions are not replicated
|
||||
CommitLogMutation.create(manifestKey, rdeRevision),
|
||||
// FKIs aren't replayed to SQL at all
|
||||
CommitLogMutation.create(manifestKey, fki));
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -33,15 +33,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.model.ofy.Ofy;
|
||||
import google.registry.model.tld.Registry;
|
||||
import google.registry.model.tld.label.PremiumList.PremiumEntry;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.InjectExtension;
|
||||
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;
|
||||
|
||||
@@ -50,19 +46,9 @@ class ReservedListTest {
|
||||
|
||||
private FakeClock clock = new FakeClock(DateTime.parse("2010-01-01T10:00:00Z"));
|
||||
|
||||
@Order(value = Order.DEFAULT - 1)
|
||||
@RegisterExtension
|
||||
final InjectExtension inject =
|
||||
new InjectExtension().withStaticFieldOverride(Ofy.class, "clock", clock);
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withClock(clock)
|
||||
.withJpaUnitTestEntities(
|
||||
PremiumList.class, PremiumEntry.class, ReservedList.class, ReservedListEntry.class)
|
||||
.withDatastoreAndCloudSql()
|
||||
.build();
|
||||
public final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder().withClock(clock).withCloudSql().build();
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach() {
|
||||
|
||||
-87
@@ -1,87 +0,0 @@
|
||||
// Copyright 2020 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.persistence.converter;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.tld.label.ReservedList;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
import org.testcontainers.shaded.com.google.common.collect.ImmutableSet;
|
||||
|
||||
/** Unit tests for {@link ReservedListKeySetConverter}. */
|
||||
class ReservedListKeySetConverterTest {
|
||||
|
||||
@RegisterExtension
|
||||
final AppEngineExtension appEngine =
|
||||
AppEngineExtension.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.withJpaUnitTestEntities(ReservedListSetEntity.class)
|
||||
.build();
|
||||
|
||||
@Test
|
||||
void roundTripConversion_returnsSameSet() {
|
||||
Key<ReservedList> key1 = Key.create(getCrossTldKey(), ReservedList.class, "test1");
|
||||
Key<ReservedList> key2 = Key.create(getCrossTldKey(), ReservedList.class, "test2");
|
||||
Key<ReservedList> key3 = Key.create(getCrossTldKey(), ReservedList.class, "test3");
|
||||
|
||||
Set<Key<ReservedList>> reservedLists = ImmutableSet.of(key1, key2, key3);
|
||||
ReservedListSetEntity testEntity = new ReservedListSetEntity(reservedLists);
|
||||
jpaTm().transact(() -> jpaTm().insert(testEntity));
|
||||
ReservedListSetEntity persisted =
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().find(ReservedListSetEntity.class, "id"));
|
||||
assertThat(persisted.reservedList).containsExactly(key1, key2, key3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullValue_writesAndReadsNullSuccessfully() {
|
||||
ReservedListSetEntity testEntity = new ReservedListSetEntity(null);
|
||||
jpaTm().transact(() -> jpaTm().insert(testEntity));
|
||||
ReservedListSetEntity persisted =
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().find(ReservedListSetEntity.class, "id"));
|
||||
assertThat(persisted.reservedList).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEmptyCollection_writesAndReadsEmptyCollectionSuccessfully() {
|
||||
ReservedListSetEntity testEntity = new ReservedListSetEntity(ImmutableSet.of());
|
||||
jpaTm().transact(() -> jpaTm().insert(testEntity));
|
||||
ReservedListSetEntity persisted =
|
||||
jpaTm().transact(() -> jpaTm().getEntityManager().find(ReservedListSetEntity.class, "id"));
|
||||
assertThat(persisted.reservedList).isEmpty();
|
||||
}
|
||||
|
||||
@Entity(name = "ReservedListSetEntity")
|
||||
private static class ReservedListSetEntity extends ImmutableObject {
|
||||
|
||||
@Id String name = "id";
|
||||
|
||||
Set<Key<ReservedList>> reservedList;
|
||||
|
||||
public ReservedListSetEntity() {}
|
||||
|
||||
ReservedListSetEntity(Set<Key<ReservedList>> reservedList) {
|
||||
this.reservedList = reservedList;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +161,6 @@ class UpdateReservedListCommandTest
|
||||
command.input = Paths.get(reservedTermsPath);
|
||||
command.init();
|
||||
|
||||
assertThat(command.prompt()).contains("Update ReservedList@xn--q9jyb4c_common-reserved");
|
||||
assertThat(command.prompt()).contains("Update reserved list for xn--q9jyb4c_common-reserved?");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,4 +19,3 @@ Recurring
|
||||
Registrar
|
||||
RegistrarContact
|
||||
Registry
|
||||
ReservedList
|
||||
|
||||
@@ -4,6 +4,5 @@ Cursor
|
||||
Registrar
|
||||
RegistrarContact
|
||||
Registry
|
||||
ReservedList
|
||||
ServerSecret
|
||||
TmchCrl
|
||||
|
||||
@@ -15,4 +15,3 @@ Recurring
|
||||
Registrar
|
||||
RegistrarContact
|
||||
Registry
|
||||
ReservedList
|
||||
|
||||
@@ -789,26 +789,6 @@ enum google.registry.model.tld.Registry$TldType {
|
||||
REAL;
|
||||
TEST;
|
||||
}
|
||||
enum google.registry.model.tld.label.ReservationType {
|
||||
ALLOWED_IN_SUNRISE;
|
||||
FULLY_BLOCKED;
|
||||
NAME_COLLISION;
|
||||
RESERVED_FOR_ANCHOR_TENANT;
|
||||
RESERVED_FOR_SPECIFIC_USE;
|
||||
}
|
||||
class google.registry.model.tld.label.ReservedList {
|
||||
@Id java.lang.String name;
|
||||
@Parent com.googlecode.objectify.Key<google.registry.model.common.EntityGroupRoot> parent;
|
||||
boolean shouldPublish;
|
||||
java.util.Map<java.lang.String, google.registry.model.tld.label.ReservedList$ReservedListEntry> reservedListMap;
|
||||
org.joda.time.DateTime creationTimestamp;
|
||||
}
|
||||
class google.registry.model.tld.label.ReservedList$ReservedListEntry {
|
||||
@Id java.lang.String domainLabel;
|
||||
google.registry.model.tld.label.ReservationType reservationType;
|
||||
java.lang.Long revisionId;
|
||||
java.lang.String comment;
|
||||
}
|
||||
class google.registry.model.tmch.ClaimsList {
|
||||
@Id long id;
|
||||
@Parent com.googlecode.objectify.Key<google.registry.model.tmch.ClaimsList$ClaimsListRevision> parent;
|
||||
|
||||
Reference in New Issue
Block a user