Cleanup HostInfoFlowTest by removing unclear boolean param

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=140399843
This commit is contained in:
cgoldfeder 2016-11-28 14:06:30 -08:00 committed by Ben McIlwain
parent f5d0de61f2
commit 9129c74201

View file

@ -14,8 +14,6 @@
package google.registry.flows.host; package google.registry.flows.host;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.isDeleted;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newDomainResource; import static google.registry.testing.DatastoreHelper.newDomainResource;
@ -50,12 +48,11 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
createTld("foobar"); createTld("foobar");
} }
private HostResource persistHostResource(boolean active) throws Exception { private HostResource persistHostResource() throws Exception {
HostResource host = persistResource( return persistResource(
new HostResource.Builder() new HostResource.Builder()
.setFullyQualifiedHostName(getUniqueIdFromCommand()) .setFullyQualifiedHostName(getUniqueIdFromCommand())
.setRepoId("1FF-FOOBAR") .setRepoId("1FF-FOOBAR")
.setDeletionTime(active ? null : clock.nowUtc().minusDays(1))
.setCurrentSponsorClientId("my sponsor") .setCurrentSponsorClientId("my sponsor")
.setStatusValues( .setStatusValues(
ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED)) ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
@ -70,13 +67,11 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
.setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z")) .setLastEppUpdateTime(DateTime.parse("1999-12-03T09:00:00.0Z"))
.setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z")) .setLastTransferTime(DateTime.parse("2000-04-08T09:00:00.0Z"))
.build()); .build());
assertThat(isDeleted(host, clock.nowUtc())).isNotEqualTo(active);
return host;
} }
@Test @Test
public void testSuccess() throws Exception { public void testSuccess() throws Exception {
persistHostResource(true); persistHostResource();
assertTransactionalFlow(false); assertTransactionalFlow(false);
// Check that the persisted host info was returned. // Check that the persisted host info was returned.
runFlowAssertResponse( runFlowAssertResponse(
@ -89,10 +84,10 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test @Test
public void testSuccess_linked() throws Exception { public void testSuccess_linked() throws Exception {
persistHostResource(true); persistHostResource();
persistResource( persistResource(
newDomainResource("example.foobar").asBuilder() newDomainResource("example.foobar").asBuilder()
.addNameservers(ImmutableSet.of(Key.create(persistHostResource(true)))) .addNameservers(ImmutableSet.of(Key.create(persistHostResource())))
.build()); .build());
assertTransactionalFlow(false); assertTransactionalFlow(false);
// Check that the persisted host info was returned. // Check that the persisted host info was returned.
@ -113,7 +108,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
.setCurrentSponsorClientId("superclientid") .setCurrentSponsorClientId("superclientid")
.build()); .build());
persistResource( persistResource(
persistHostResource(true).asBuilder() persistHostResource().asBuilder()
.setRepoId("CEEF-FOOBAR") .setRepoId("CEEF-FOOBAR")
.setSuperordinateDomain(Key.create(domain)) .setSuperordinateDomain(Key.create(domain))
.setLastSuperordinateChange(lastSuperordinateChange) .setLastSuperordinateChange(lastSuperordinateChange)
@ -156,7 +151,8 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
@Test @Test
public void testFailure_existedButWasDeleted() throws Exception { public void testFailure_existedButWasDeleted() throws Exception {
persistHostResource(false); persistResource(
persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build());
thrown.expect( thrown.expect(
ResourceDoesNotExistException.class, ResourceDoesNotExistException.class,
String.format("(%s)", getUniqueIdFromCommand())); String.format("(%s)", getUniqueIdFromCommand()));