From f969e58025a45ac6a3970c439f2fb429b6a6d30e Mon Sep 17 00:00:00 2001 From: mcilwain Date: Fri, 30 Sep 2016 14:27:32 -0700 Subject: [PATCH] Make DatastoreHelper set creation time to START_OF_TIME for contacts It was already doing this for domains and hosts, and that it wasn't doing it for contacts was confusing and caused me to experience a difficult-to-track-down error in writing new code. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134827468 --- .../VerifyEntityIntegrityActionTest.java | 31 ++++++++++++++++--- .../registry/testing/DatastoreHelper.java | 1 + 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java b/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java index 19dc2e7ae..039aae707 100644 --- a/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java +++ b/javatests/google/registry/monitoring/whitebox/VerifyEntityIntegrityActionTest.java @@ -17,14 +17,15 @@ package google.registry.monitoring.whitebox; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.deleteResource; +import static google.registry.testing.DatastoreHelper.newContactResource; import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveHost; -import static google.registry.testing.DatastoreHelper.persistDeletedContact; import static google.registry.testing.DatastoreHelper.persistDomainAsDeleted; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResource; +import static org.joda.time.DateTimeZone.UTC; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; @@ -147,10 +148,30 @@ public class VerifyEntityIntegrityActionTest .asBuilder() .setCreationTimeForTest(now.minusMonths(3)) .build()); - persistDeletedContact("ricketycricket", now.minusDays(3)); - persistDeletedContact("ricketycricket", now.minusDays(2)); - persistDeletedContact("ricketycricket", now.minusDays(1)); - persistActiveContact("ricketycricket"); + DateTime now = DateTime.now(UTC); + persistResource( + newContactResource("ricketycricket") + .asBuilder() + .setCreationTimeForTest(now.minusDays(10)) + .setDeletionTime(now.minusDays(9)) + .build()); + persistResource( + newContactResource("ricketycricket") + .asBuilder() + .setCreationTimeForTest(now.minusDays(7)) + .setDeletionTime(now.minusDays(6)) + .build()); + persistResource( + newContactResource("ricketycricket") + .asBuilder() + .setCreationTimeForTest(now.minusDays(4)) + .setDeletionTime(now.minusDays(3)) + .build()); + persistResource( + newContactResource("ricketycricket") + .asBuilder() + .setCreationTimeForTest(now.minusDays(1)) + .build()); persistActiveHost("ns9001.example.net"); runMapreduce(); verifyZeroInteractions(bigquery); diff --git a/javatests/google/registry/testing/DatastoreHelper.java b/javatests/google/registry/testing/DatastoreHelper.java index 7d5864424..d20e5a4c1 100644 --- a/javatests/google/registry/testing/DatastoreHelper.java +++ b/javatests/google/registry/testing/DatastoreHelper.java @@ -218,6 +218,7 @@ public class DatastoreHelper { .setContactId(contactId) .setCurrentSponsorClientId("TheRegistrar") .setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("2fooBAR"))) + .setCreationTimeForTest(START_OF_TIME) .build(); }