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
This commit is contained in:
mcilwain 2016-09-30 14:27:32 -07:00 committed by Ben McIlwain
parent d0c102e680
commit f969e58025
2 changed files with 27 additions and 5 deletions

View file

@ -17,14 +17,15 @@ package google.registry.monitoring.whitebox;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.deleteResource; 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.newDomainResource;
import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistActiveDomain; import static google.registry.testing.DatastoreHelper.persistActiveDomain;
import static google.registry.testing.DatastoreHelper.persistActiveHost; 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.persistDomainAsDeleted;
import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistSimpleResource; 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.any;
import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@ -147,10 +148,30 @@ public class VerifyEntityIntegrityActionTest
.asBuilder() .asBuilder()
.setCreationTimeForTest(now.minusMonths(3)) .setCreationTimeForTest(now.minusMonths(3))
.build()); .build());
persistDeletedContact("ricketycricket", now.minusDays(3)); DateTime now = DateTime.now(UTC);
persistDeletedContact("ricketycricket", now.minusDays(2)); persistResource(
persistDeletedContact("ricketycricket", now.minusDays(1)); newContactResource("ricketycricket")
persistActiveContact("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"); persistActiveHost("ns9001.example.net");
runMapreduce(); runMapreduce();
verifyZeroInteractions(bigquery); verifyZeroInteractions(bigquery);

View file

@ -218,6 +218,7 @@ public class DatastoreHelper {
.setContactId(contactId) .setContactId(contactId)
.setCurrentSponsorClientId("TheRegistrar") .setCurrentSponsorClientId("TheRegistrar")
.setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("2fooBAR"))) .setAuthInfo(ContactAuthInfo.create(PasswordAuth.create("2fooBAR")))
.setCreationTimeForTest(START_OF_TIME)
.build(); .build();
} }