use of software.amazon.awssdk.services.dynamodb.model.ScanResponse in project iep by Netflix.
the class PaginationTest method dynamoDB.
@Test
public void dynamoDB() throws Exception {
Map<String, AttributeValue> nextPage = new HashMap<>();
nextPage.put("abc", AttributeValue.builder().build());
Map<String, AttributeValue> donePage = new HashMap<>();
Function<ScanRequest, ScanResponse> f = r -> {
if (r.exclusiveStartKey() != null) {
Assert.assertTrue(r.exclusiveStartKey().containsKey("abc"));
}
return ScanResponse.builder().lastEvaluatedKey((r.exclusiveStartKey() == null) ? nextPage : donePage).build();
};
Publisher<ScanResponse> publisher = Pagination.createPublisher(ScanRequest.builder().build(), f);
Iterable<ScanResponse> iter = Flowable.fromPublisher(publisher).blockingIterable();
int count = 0;
for (ScanResponse r : iter) {
++count;
}
Assert.assertEquals(2, count);
}
Aggregations