Fix confusing "now" parameters on persist deleted helper methods

They were taking a DateTime "now", which would seem like it would be the time of
when the resource was deleted, but it was actually the time by which the
resource was deleted, with the actual deletion time being hardcoded to a day
prior.  The confusion was evident because a fair number of tests were passing
the wrong thing.  I renamed the parameter "deletionTime" to make it exactly
clear what it's doing and fixed up some callsites where necessary.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=134818032
This commit is contained in:
mcilwain 2016-09-30 13:10:08 -07:00 committed by Ben McIlwain
parent 35d5307706
commit c517c98d17
23 changed files with 63 additions and 53 deletions

View file

@ -52,7 +52,7 @@ public class ContactCheckFlowTest
@Test
public void testOneExistsButWasDeleted() throws Exception {
persistDeletedContact("sh8013", clock.nowUtc());
persistDeletedContact("sh8013", clock.nowUtc().minusDays(1));
// These ids come from the check xml.
doCheckTest(
create(true, "sh8013", null),

View file

@ -58,7 +58,7 @@ public class ContactCreateFlowTest
@Test
public void testSuccess_existedButWasDeleted() throws Exception {
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
clock.advanceOneMilli();
doSuccessfulTest();
}

View file

@ -88,7 +88,7 @@ public class ContactDeleteFlowTest
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -161,7 +161,7 @@ public class ContactUpdateFlowTest
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedContact(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -259,7 +259,7 @@ public class DomainAllocateFlowTest
@Test
public void testSuccess_existedButWasDeleted() throws Exception {
setupDomainApplication("tld", TldState.QUIET_PERIOD);
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
clock.advanceOneMilli();
doSuccessfulTest(2);
}

View file

@ -139,7 +139,7 @@ public class DomainCheckFlowTest
@Test
public void testSuccess_oneExistsButWasDeleted() throws Exception {
persistDeletedDomain("example1.tld", clock.nowUtc());
persistDeletedDomain("example1.tld", clock.nowUtc().minusDays(1));
doCheckTest(
create(true, "example1.tld", null),
create(true, "example2.tld", null),
@ -804,7 +804,7 @@ public class DomainCheckFlowTest
runEapFeeCheckTest("domain_check_fee_date_v12.xml",
"domain_check_eap_fee_response_date_v12.xml");
}
@Ignore
@Test
public void testSuccess_feeCheck_multipleRanges() throws Exception {

View file

@ -234,7 +234,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
.build();
}
assertBillingEvents(billingEvents);
assertGracePeriods(
domain.getGracePeriods(),
ImmutableMap.of(
@ -523,7 +523,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test
public void testSuccess_existedButWasDeleted() throws Exception {
persistContactsAndHosts();
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
clock.advanceOneMilli();
doSuccessfulTest();
}

View file

@ -603,7 +603,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -390,7 +390,7 @@ public class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, D
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -454,7 +454,7 @@ public class DomainRestoreRequestFlowTest extends
@Test
public void testFailure_fullyDeleted() throws Exception {
thrown.expect(ResourceDoesNotExistException.class);
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -830,7 +830,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistReferencedEntities();
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedDomain(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -51,7 +51,7 @@ public class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow,
@Test
public void testOneExistsButWasDeleted() throws Exception {
persistDeletedHost("ns1.example.tld", clock.nowUtc());
persistDeletedHost("ns1.example.tld", clock.nowUtc().minusDays(1));
// These ids come from the check xml.
doCheckTest(
create(true, "ns1.example.tld", null),

View file

@ -114,14 +114,14 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
@Test
public void testSuccess_externalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulTest();
assertNoDnsTasksEnqueued();
}
@Test
public void testSuccess_internalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulInternalTest("tld");
assertThat(ofy().load().key(reloadResourceByForeignKey().getSuperordinateDomain())
.now().getFullyQualifiedDomainName())

View file

@ -90,7 +90,7 @@ public class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Hos
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc());
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
runFlow();
}

View file

@ -675,7 +675,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
@Test
public void testFailure_existedButWasDeleted() throws Exception {
persistDeletedHost(oldHostName(), clock.nowUtc());
persistDeletedHost(oldHostName(), clock.nowUtc().minusDays(1));
thrown.expect(
ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand()));