Ensure that poll messages are created in domain create flow tests

Also ensures that a custom logic hook is called on create.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=143112481
This commit is contained in:
mcilwain 2016-12-28 09:25:50 -08:00 committed by Ben McIlwain
parent 1c927a48e9
commit 393eeabc5e
6 changed files with 142 additions and 4 deletions

View file

@ -657,6 +657,22 @@ public class DatastoreHelper {
return billingEvent.asBuilder().setId(1L).build();
}};
public static void assertPollMessagesForResource(EppResource resource, PollMessage... expected)
throws Exception {
assertThat(FluentIterable.from(getPollMessages(resource)).transform(POLL_MESSAGE_ID_STRIPPER))
.containsExactlyElementsIn(
FluentIterable.from(asList(expected)).transform(POLL_MESSAGE_ID_STRIPPER));
}
/** Helper to effectively erase the poll message ID to facilitate comparison. */
public static final Function<PollMessage, PollMessage> POLL_MESSAGE_ID_STRIPPER =
new Function<PollMessage, PollMessage>() {
@Override
public PollMessage apply(PollMessage pollMessage) {
// Can't use id=0 because that causes the builder to generate a new id.
return pollMessage.asBuilder().setId(1L).build();
}};
public static ImmutableList<PollMessage> getPollMessages() {
return FluentIterable.from(ofy().load().type(PollMessage.class)).toList();
}
@ -667,6 +683,10 @@ public class DatastoreHelper {
.toList();
}
public static ImmutableList<PollMessage> getPollMessages(EppResource resource) {
return FluentIterable.from(ofy().load().type(PollMessage.class).ancestor(resource)).toList();
}
public static ImmutableList<PollMessage> getPollMessages(String clientId, DateTime now) {
return FluentIterable
.from(ofy()