Fix TaskQueueHelper param matching for pull queue tasks

This fixes TaskQueueHelper methods and MatchableTaskInfo so that the .param() matching works for pull queues, by parsing the payload for URL-encoded parameters more liberally.  As such, it updates all the places where formerly we were hacking around this by manually constructing the expected payloads and using TaskMatcher.payload() instead.

It also adds a TaskQueueHelper.assertTasksEnqueued() overload that accepts an Iterable<TaskStateInfo> so that you can cleanly assert that a queue contains the same tasks that were returned via a previous call to getQueueInfo("queue").getTaskInfo().

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=156604901
This commit is contained in:
nickfelt 2017-05-19 15:30:41 -07:00 committed by Ben McIlwain
parent 481d57cd41
commit 65aaeccfc6
7 changed files with 71 additions and 31 deletions

View file

@ -158,20 +158,15 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
/** Asserts the presence of a single enqueued async contact or host deletion */
protected static <T extends EppResource> void assertAsyncDeletionTaskEnqueued(
T resource, String requestingClientId, Trid trid, boolean isSuperuser) throws Exception {
String expectedPayload =
String.format(
"resourceKey=%s&requestingClientId=%s&clientTransactionId=%s&"
+ "serverTransactionId=%s&isSuperuser=%s",
Key.create(resource).getString(),
requestingClientId,
trid.getClientTransactionId(),
trid.getServerTransactionId(),
Boolean.toString(isSuperuser));
assertTasksEnqueued(
"async-delete-pull",
new TaskMatcher()
.etaDelta(Duration.standardSeconds(75), Duration.standardSeconds(105)) // expected: 90
.payload(expectedPayload));
.param("resourceKey", Key.create(resource).getString())
.param("requestingClientId", requestingClientId)
.param("clientTransactionId", trid.getClientTransactionId())
.param("serverTransactionId", trid.getServerTransactionId())
.param("isSuperuser", Boolean.toString(isSuperuser)));
}