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
This commit is contained in:
nickfelt 2017-04-26 12:46:15 -07:00 committed by Ben McIlwain
parent d30f9411d8
commit 40fa9ff022
3 changed files with 6 additions and 13 deletions

View file

@ -35,7 +35,6 @@ import google.registry.model.domain.DomainApplication;
import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainBase;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; 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;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.request.Action; import google.registry.request.Action;
@ -137,7 +136,7 @@ public class DeleteProberDataAction implements Runnable {
} }
final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey)); final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey));
final Key<ForeignKeyIndex<?>> fki = ForeignKeyDomainIndex.createKey(domain); final Key<ForeignKeyIndex<?>> fki = ForeignKeyIndex.createKey(domain);
int entitiesDeleted = ofy().transact(new Work<Integer>() { int entitiesDeleted = ofy().transact(new Work<Integer>() {
@Override @Override

View file

@ -50,9 +50,6 @@ import google.registry.model.domain.DomainResource;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex; 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.FakeClock;
import google.registry.testing.FakeResponse; import google.registry.testing.FakeResponse;
import google.registry.testing.FakeSleeper; import google.registry.testing.FakeSleeper;
@ -219,7 +216,7 @@ public class VerifyEntityIntegrityActionTest
runMapreduce(); runMapreduce();
assertIntegrityErrors( assertIntegrityErrors(
IntegrityError.create( IntegrityError.create(
ForeignKeyDomainIndex.createKey(domain2), ForeignKeyIndex.createKey(domain2),
Key.create(domain1), Key.create(domain1),
"Found inactive resource deleted more recently than when active resource was created")); "Found inactive resource deleted more recently than when active resource was created"));
} }
@ -231,11 +228,11 @@ public class VerifyEntityIntegrityActionTest
runMapreduce(); runMapreduce();
assertIntegrityErrors( assertIntegrityErrors(
IntegrityError.create( IntegrityError.create(
Key.create(ForeignKeyContactIndex.class, "dupeid"), ForeignKeyIndex.createKey(contact1),
Key.create(contact1), Key.create(contact1),
"Multiple active EppResources with same foreign key"), "Multiple active EppResources with same foreign key"),
IntegrityError.create( IntegrityError.create(
Key.create(ForeignKeyContactIndex.class, "dupeid"), ForeignKeyIndex.createKey(contact2),
Key.create(contact2), Key.create(contact2),
"Multiple active EppResources with same foreign key")); "Multiple active EppResources with same foreign key"));
} }
@ -246,7 +243,7 @@ public class VerifyEntityIntegrityActionTest
persistResource( persistResource(
hostLosing.asBuilder().setFullyQualifiedHostName("gaining.example.tld").build()); hostLosing.asBuilder().setFullyQualifiedHostName("gaining.example.tld").build());
persistSimpleResource( 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 // 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 // resource which has a hostname of "gaining.example.tld", but this isn't an error because the
// FKI is soft-deleted. // FKI is soft-deleted.
@ -264,7 +261,7 @@ public class VerifyEntityIntegrityActionTest
.setDeletionTime(DateTime.parse("2013-01-01T00:00:00Z")) .setDeletionTime(DateTime.parse("2013-01-01T00:00:00Z"))
.build()); .build());
ForeignKeyIndex<?> fki = persistSimpleResource( 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 // 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. // host, so it should have the same foreign key.
runMapreduce(); runMapreduce();

View file

@ -20,7 +20,6 @@ import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newHostResource; import static google.registry.testing.DatastoreHelper.newHostResource;
import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistResource; 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.GcsFilename;
import com.google.appengine.tools.cloudstorage.GcsService; import com.google.appengine.tools.cloudstorage.GcsService;
@ -35,7 +34,6 @@ import google.registry.gcs.GcsUtils;
import google.registry.mapreduce.MapreduceRunner; import google.registry.mapreduce.MapreduceRunner;
import google.registry.model.domain.DomainResource; import google.registry.model.domain.DomainResource;
import google.registry.model.host.HostResource; import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex.ForeignKeyDomainIndex;
import google.registry.request.Response; import google.registry.request.Response;
import google.registry.testing.FakeResponse; import google.registry.testing.FakeResponse;
import google.registry.testing.mapreduce.MapreduceTestCase; import google.registry.testing.mapreduce.MapreduceTestCase;
@ -83,7 +81,6 @@ public class RdeHostLinkActionTest extends MapreduceTestCase<RdeHostLinkAction>
.setRepoId("Hns1_example1_test-TEST") .setRepoId("Hns1_example1_test-TEST")
.build()); .build());
DomainResource superordinateDomain = persistActiveDomain("example1.test"); DomainResource superordinateDomain = persistActiveDomain("example1.test");
ForeignKeyDomainIndex.create(superordinateDomain, END_OF_TIME);
Key<DomainResource> superOrdinateDomainKey = Key.create(superordinateDomain); Key<DomainResource> superOrdinateDomainKey = Key.create(superordinateDomain);
pushToGcs(DEPOSIT_1_HOST); pushToGcs(DEPOSIT_1_HOST);
runMapreduce(); runMapreduce();