Rename Registries to Tlds (#2042)

* Rename Registries to Tlds

* Change Tlds to TLDs in comments
This commit is contained in:
sarahcaseybot
2023-05-24 17:08:09 -04:00
committed by GitHub
parent 36a60bdf8b
commit fddecea18e
41 changed files with 81 additions and 82 deletions
@@ -42,9 +42,9 @@ import google.registry.config.RegistryConfig;
import google.registry.model.EntityTestCase;
import google.registry.model.registrar.Registrar.State;
import google.registry.model.registrar.Registrar.Type;
import google.registry.model.tld.Registries;
import google.registry.model.tld.Tld;
import google.registry.model.tld.Tld.TldType;
import google.registry.model.tld.Tlds;
import google.registry.util.CidrAddressBlock;
import google.registry.util.SerializeUtils;
import java.math.BigDecimal;
@@ -603,14 +603,14 @@ class RegistrarTest extends EntityTestCase {
// Cache duration in tests is 0. To make sure the data isn't in the cache we have to set it
// to a higher value and reset the cache.
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds = 600;
Registries.resetCache();
Tlds.resetCache();
// Make sure the TLD we want to create doesn't exist yet.
// This is also important because getTlds fills out the cache when used.
assertThat(Registries.getTlds()).doesNotContain("newtld");
assertThat(Tlds.getTlds()).doesNotContain("newtld");
// We can't use createTld here because it fails when the cache is used.
persistResource(newTld("newtld", "NEWTLD"));
// Make sure we set up the cache correctly, so the newly created TLD isn't in the cache
assertThat(Registries.getTlds()).doesNotContain("newtld");
assertThat(Tlds.getTlds()).doesNotContain("newtld");
// Test that the uncached version works
assertThat(
@@ -633,11 +633,11 @@ class RegistrarTest extends EntityTestCase {
// Make sure the cache hasn't expired during the test and "newtld" is still not in the cached
// TLDs
assertThat(Registries.getTlds()).doesNotContain("newtld");
assertThat(Tlds.getTlds()).doesNotContain("newtld");
} finally {
RegistryConfig.CONFIG_SETTINGS.get().caching.singletonCacheRefreshSeconds =
origSingletonCacheRefreshSeconds;
Registries.resetCache();
Tlds.resetCache();
}
}
@@ -28,8 +28,8 @@ import google.registry.persistence.transaction.JpaTestExtensions.JpaIntegrationT
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link Registries}. */
class RegistriesTest {
/** Unit tests for {@link Tlds}. */
class TldsTest {
@RegisterExtension
final JpaIntegrationTestExtension jpa =
@@ -42,51 +42,51 @@ class RegistriesTest {
@Test
void testGetTlds() {
initTestTlds();
assertThat(Registries.getTlds()).containsExactly("foo", "a.b.c");
assertThat(Tlds.getTlds()).containsExactly("foo", "a.b.c");
}
@Test
void test_getTldEntities() {
initTestTlds();
persistResource(newTld("testtld", "TESTTLD").asBuilder().setTldType(TldType.TEST).build());
assertThat(Registries.getTldEntitiesOfType(TldType.REAL))
assertThat(Tlds.getTldEntitiesOfType(TldType.REAL))
.containsExactly(Tld.get("foo"), Tld.get("a.b.c"));
assertThat(Registries.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld"));
assertThat(Tlds.getTldEntitiesOfType(TldType.TEST)).containsExactly(Tld.get("testtld"));
}
@Test
void testGetTlds_withNoRegistriesPersisted_returnsEmptySet() {
assertThat(Registries.getTlds()).isEmpty();
assertThat(Tlds.getTlds()).isEmpty();
}
@Test
void testAssertTldExists_doesExist() {
initTestTlds();
Registries.assertTldExists("foo");
Registries.assertTldExists("a.b.c");
Tlds.assertTldExists("foo");
Tlds.assertTldExists("a.b.c");
}
@Test
void testAssertTldExists_doesntExist() {
initTestTlds();
assertThrows(IllegalArgumentException.class, () -> Registries.assertTldExists("baz"));
assertThrows(IllegalArgumentException.class, () -> Tlds.assertTldExists("baz"));
}
@Test
void testFindTldForName() {
initTestTlds();
assertThat(Registries.findTldForName(InternetDomainName.from("example.foo")).get().toString())
assertThat(Tlds.findTldForName(InternetDomainName.from("example.foo")).get().toString())
.isEqualTo("foo");
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b.c")).get().toString())
assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.a.b.c")).get().toString())
.isEqualTo("a.b.c");
// We don't have an "example" tld.
assertThat(Registries.findTldForName(InternetDomainName.from("foo.example"))).isEmpty();
assertThat(Tlds.findTldForName(InternetDomainName.from("foo.example"))).isEmpty();
// A tld is not a match for itself.
assertThat(Registries.findTldForName(InternetDomainName.from("foo"))).isEmpty();
assertThat(Tlds.findTldForName(InternetDomainName.from("foo"))).isEmpty();
// The name must match the entire tld.
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.a.b"))).isEmpty();
assertThat(Registries.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty();
assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.a.b"))).isEmpty();
assertThat(Tlds.findTldForName(InternetDomainName.from("x.y.b.c"))).isEmpty();
// Substring tld matches aren't considered.
assertThat(Registries.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty();
assertThat(Tlds.findTldForName(InternetDomainName.from("example.barfoo"))).isEmpty();
}
}
@@ -19,7 +19,7 @@ import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.EppResourceUtils.loadByForeignKeyCached;
import static google.registry.model.registrar.Registrar.State.ACTIVE;
import static google.registry.model.registrar.Registrar.Type.PDT;
import static google.registry.model.tld.Registries.getTlds;
import static google.registry.model.tld.Tlds.getTlds;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;