From 40fa9ff02293fcd994da8c1a824432894e9ae633 Mon Sep 17 00:00:00 2001 From: nickfelt Date: Wed, 26 Apr 2017 12:46:15 -0700 Subject: [PATCH] Fix some direct uses of ForeignKey(C/H/D)Index Mostly these are calls to ForeignKeyIndex.create() (a static method) via subclasses, which is pretty misleading in this case since the type of the return value has nothing to do with the subclass you're qualifying the static method call with (the returned type depends only on the type of the EppResource parameter). Note however though that while the style guide indeed prohibits qualifying static member references with things other than the class name, the subclassing case is apparently not considered subject to that prohibition in general: https://groups.google.com[]d/msg/java-style/8ViX-Rh2_sc/48n2lz5nAAAJ ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=154331605 --- .../registry/batch/DeleteProberDataAction.java | 3 +-- .../batch/VerifyEntityIntegrityActionTest.java | 13 +++++-------- .../registry/rde/imports/RdeHostLinkActionTest.java | 3 --- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/java/google/registry/batch/DeleteProberDataAction.java b/java/google/registry/batch/DeleteProberDataAction.java index b65ca16ad..026a56c0f 100644 --- a/java/google/registry/batch/DeleteProberDataAction.java +++ b/java/google/registry/batch/DeleteProberDataAction.java @@ -35,7 +35,6 @@ import google.registry.model.domain.DomainApplication; import google.registry.model.domain.DomainBase; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldType; import google.registry.request.Action; @@ -137,7 +136,7 @@ public class DeleteProberDataAction implements Runnable { } final Key eppIndex = Key.create(EppResourceIndex.create(domainKey)); - final Key> fki = ForeignKeyDomainIndex.createKey(domain); + final Key> fki = ForeignKeyIndex.createKey(domain); int entitiesDeleted = ofy().transact(new Work() { @Override diff --git a/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java index 60f1514c5..163f4067f 100644 --- a/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java +++ b/javatests/google/registry/batch/VerifyEntityIntegrityActionTest.java @@ -50,9 +50,6 @@ import google.registry.model.domain.DomainResource; import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyContactIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; @@ -219,7 +216,7 @@ public class VerifyEntityIntegrityActionTest runMapreduce(); assertIntegrityErrors( IntegrityError.create( - ForeignKeyDomainIndex.createKey(domain2), + ForeignKeyIndex.createKey(domain2), Key.create(domain1), "Found inactive resource deleted more recently than when active resource was created")); } @@ -231,11 +228,11 @@ public class VerifyEntityIntegrityActionTest runMapreduce(); assertIntegrityErrors( IntegrityError.create( - Key.create(ForeignKeyContactIndex.class, "dupeid"), + ForeignKeyIndex.createKey(contact1), Key.create(contact1), "Multiple active EppResources with same foreign key"), IntegrityError.create( - Key.create(ForeignKeyContactIndex.class, "dupeid"), + ForeignKeyIndex.createKey(contact2), Key.create(contact2), "Multiple active EppResources with same foreign key")); } @@ -246,7 +243,7 @@ public class VerifyEntityIntegrityActionTest persistResource( hostLosing.asBuilder().setFullyQualifiedHostName("gaining.example.tld").build()); persistSimpleResource( - ForeignKeyHostIndex.create(hostLosing, DateTime.parse("2010-01-01T00:00:00Z"))); + ForeignKeyIndex.create(hostLosing, DateTime.parse("2010-01-01T00:00:00Z"))); // The old FKI with a primary key of "losing.example.tld" still exists, and it points to the // resource which has a hostname of "gaining.example.tld", but this isn't an error because the // FKI is soft-deleted. @@ -264,7 +261,7 @@ public class VerifyEntityIntegrityActionTest .setDeletionTime(DateTime.parse("2013-01-01T00:00:00Z")) .build()); ForeignKeyIndex fki = persistSimpleResource( - ForeignKeyHostIndex.create(hostLosing, DateTime.parse("2014-01-01T00:00:00Z"))); + ForeignKeyIndex.create(hostLosing, DateTime.parse("2014-01-01T00:00:00Z"))); // The old FKI is pointing to the old name but has a deletion time more recent than the deleted // host, so it should have the same foreign key. runMapreduce(); diff --git a/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java b/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java index 9967aa393..968b9125d 100644 --- a/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java +++ b/javatests/google/registry/rde/imports/RdeHostLinkActionTest.java @@ -20,7 +20,6 @@ import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistResource; -import static google.registry.util.DateTimeUtils.END_OF_TIME; import com.google.appengine.tools.cloudstorage.GcsFilename; import com.google.appengine.tools.cloudstorage.GcsService; @@ -35,7 +34,6 @@ import google.registry.gcs.GcsUtils; import google.registry.mapreduce.MapreduceRunner; import google.registry.model.domain.DomainResource; import google.registry.model.host.HostResource; -import google.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex; import google.registry.request.Response; import google.registry.testing.FakeResponse; import google.registry.testing.mapreduce.MapreduceTestCase; @@ -83,7 +81,6 @@ public class RdeHostLinkActionTest extends MapreduceTestCase .setRepoId("Hns1_example1_test-TEST") .build()); DomainResource superordinateDomain = persistActiveDomain("example1.test"); - ForeignKeyDomainIndex.create(superordinateDomain, END_OF_TIME); Key superOrdinateDomainKey = Key.create(superordinateDomain); pushToGcs(DEPOSIT_1_HOST); runMapreduce();