public void jumpNextPage() throws Exception {
final String jeff = "Jeff";
final String mark = "Mark";
final String judy = "Judy";
final String jessy = "Jessy";
final MkContainer container = new MkGrizzlyContainer().next(
RtValuePaginationTest.simple(jeff, mark)
.withHeader("Link", "</s?page=3&per_page=100>; rel=\"next\"")
).next(RtValuePaginationTest.simple(judy, jessy)).start();
final Request request = new ApacheRequest(container.home());
final RtValuePagination<JsonObject, JsonArray> page =
new RtValuePagination<JsonObject, JsonArray>(
request,
new RtValuePagination.Mapping<JsonObject, JsonArray>() {
@Override
public JsonObject map(final JsonArray object) {
return Json.createObjectBuilder()
.add("id1", object.getString(0))
.add("id2", object.getString(1))
.build();
}
}
);
final Iterator<JsonObject> iterator = page.iterator();
MatcherAssert.assertThat(
iterator.next().toString(),
Matchers.allOf(
Matchers.containsString(jeff),
Matchers.containsString(mark)
)
);
MatcherAssert.assertThat(
iterator.next().toString(),
Matchers.allOf(
Matchers.containsString(judy),
Matchers.containsString(jessy)
)
);
container.stop();
}