mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Change transfer flow tests to assert on entire TransferData contents
This CL changes the domain and contact transfer flows to check the entire TransferData on the post-transfer resource, rather than just spot-checking certain fields. This approach provides much better code coverage - in particular, it checks that the non-request flows (approve, cancel, reject) don't modify the fields that they shouldn't be modifying, and that they do actually clear out the transfer server-approve entities fields written by the transfer request flow. It's slightly orthogonal, but I also added testing that the server-approve entities fields are actually set in the request flows, which was previously untested. This is pre-work for introducing an exDate-storing field into TransferData, by making it easier to test everywhere that exDate is set *and* unset only in the correct places. As part of this CL, I've introduced a TransferData.copyConstantFieldsToBuilder() method that is like asBuilder() but instead of copying all the fields to the new builder, it only copies the logically constant ones: losing/gaining client IDs, the request time and TRID, and transferPeriod. This is useful both in tests but is also used in the resolvingPendingTransfer() helper that centralizes the core transfer resolution logic (as of [] That method has its own tests, and in the process I removed a bunch of crufty defunct TransferData tests. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171053454
This commit is contained in:
parent
3584bbde53
commit
7e68ffa16a
17 changed files with 363 additions and 297 deletions
|
@ -99,6 +99,7 @@ import google.registry.model.transfer.TransferData.Builder;
|
|||
import google.registry.model.transfer.TransferData.TransferServerApproveEntity;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
import google.registry.tmch.LordnTask;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -645,19 +646,27 @@ public class DatastoreHelper {
|
|||
ofy().load().type(BillingEvent.Cancellation.class).ancestor(resource));
|
||||
}
|
||||
|
||||
/** Assert that the actual billing event matches the expected one, ignoring IDs. */
|
||||
public static void assertBillingEventsEqual(BillingEvent actual, BillingEvent expected) {
|
||||
assertThat(BILLING_EVENT_ID_STRIPPER.apply(actual))
|
||||
.isEqualTo(BILLING_EVENT_ID_STRIPPER.apply(expected));
|
||||
}
|
||||
|
||||
/** Assert that the actual billing events match the expected ones, ignoring IDs and order. */
|
||||
public static void assertBillingEventsEqual(
|
||||
Iterable<BillingEvent> actual, Iterable<BillingEvent> expected) {
|
||||
assertThat(Iterables.transform(actual, BILLING_EVENT_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(Iterables.transform(expected, BILLING_EVENT_ID_STRIPPER));
|
||||
}
|
||||
|
||||
/** Assert that the expected billing events are exactly the ones found in the fake Datastore. */
|
||||
public static void assertBillingEvents(BillingEvent... expected) throws Exception {
|
||||
assertThat(FluentIterable.from(getBillingEvents()).transform(BILLING_EVENT_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(
|
||||
FluentIterable.from(expected).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
assertBillingEventsEqual(getBillingEvents(), Arrays.asList(expected));
|
||||
}
|
||||
|
||||
/** Assert that the expected billing events set is exactly the one found in the fake Datastore. */
|
||||
public static void assertBillingEvents(ImmutableSet<BillingEvent> expected) throws Exception {
|
||||
assertThat(FluentIterable.from(getBillingEvents()).transform(BILLING_EVENT_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(
|
||||
FluentIterable.from(expected.asList()).transform(BILLING_EVENT_ID_STRIPPER));
|
||||
assertBillingEventsEqual(getBillingEvents(), expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -684,6 +693,19 @@ public class DatastoreHelper {
|
|||
return billingEvent.asBuilder().setId(1L).build();
|
||||
}};
|
||||
|
||||
/** Assert that the actual poll message matches the expected one, ignoring IDs. */
|
||||
public static void assertPollMessagesEqual(PollMessage actual, PollMessage expected) {
|
||||
assertThat(POLL_MESSAGE_ID_STRIPPER.apply(actual))
|
||||
.isEqualTo(POLL_MESSAGE_ID_STRIPPER.apply(expected));
|
||||
}
|
||||
|
||||
/** Assert that the actual poll messages match the expected ones, ignoring IDs and order. */
|
||||
public static void assertPollMessagesEqual(
|
||||
Iterable<PollMessage> actual, Iterable<PollMessage> expected) {
|
||||
assertThat(Iterables.transform(actual, POLL_MESSAGE_ID_STRIPPER))
|
||||
.containsExactlyElementsIn(Iterables.transform(expected, POLL_MESSAGE_ID_STRIPPER));
|
||||
}
|
||||
|
||||
public static void assertPollMessagesForResource(EppResource resource, PollMessage... expected)
|
||||
throws Exception {
|
||||
assertThat(FluentIterable.from(getPollMessages(resource)).transform(POLL_MESSAGE_ID_STRIPPER))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue