use of software.amazon.awssdk.services.elasticloadbalancingv2.model.DescribeTargetGroupsRequest in project iep by Netflix.
the class PaginationTest method elbv2.
@Test
public void elbv2() throws Exception {
SortedSet<String> pages = newPageSet(5);
final Iterator<String> reqIt = pages.iterator();
final Iterator<String> resIt = pages.iterator();
Function<DescribeTargetGroupsRequest, DescribeTargetGroupsResult> f = r -> {
if (r.getMarker() != null) {
Assert.assertEquals(reqIt.next(), r.getMarker());
}
return new DescribeTargetGroupsResult().withNextMarker(resIt.hasNext() ? resIt.next() : null);
};
Publisher<DescribeTargetGroupsResult> publisher = Pagination.createPublisher(new DescribeTargetGroupsRequest(), f);
Iterable<String> iter = Flowable.fromPublisher(publisher).filter(r -> r.getNextMarker() != null).map(DescribeTargetGroupsResult::getNextMarker).blockingIterable();
SortedSet<String> results = new TreeSet<>();
for (String s : iter) {
results.add(s);
}
Assert.assertEquals(pages, results);
Assert.assertFalse(reqIt.hasNext());
}
Aggregations