use of software.amazon.awssdk.core.pagination.sync.SdkIterable in project aws-sdk-java-v2 by aws.
the class BatchGetItemTest method responseWithUnprocessedKeys_iterateItems_shouldFetchUnprocessedKeys.
@Test
public void responseWithUnprocessedKeys_iterateItems_shouldFetchUnprocessedKeys() {
stubResponseWithUnprocessedKeys();
BatchGetResultPageIterable batchGetResultPages = enhancedClient.batchGetItem(r -> r.readBatches(ReadBatch.builder(Record.class).mappedTableResource(table).addGetItem(i -> i.key(k -> k.partitionValue("1"))).build()));
SdkIterable<Record> results = batchGetResultPages.resultsForTable(table);
assertThat(results.stream().count()).isEqualTo(3);
}
use of software.amazon.awssdk.core.pagination.sync.SdkIterable in project aws-sdk-java-v2 by aws.
the class BatchGetItemTest method responseWithUnprocessedKeys_iteratePage_shouldFetchUnprocessedKeys.
@Test
public void responseWithUnprocessedKeys_iteratePage_shouldFetchUnprocessedKeys() {
stubResponseWithUnprocessedKeys();
SdkIterable<BatchGetResultPage> batchGetResultPages = enhancedClient.batchGetItem(r -> r.readBatches(ReadBatch.builder(Record.class).mappedTableResource(table).addGetItem(i -> i.key(k -> k.partitionValue("1"))).build()));
Iterator<BatchGetResultPage> iterator = batchGetResultPages.iterator();
BatchGetResultPage firstPage = iterator.next();
List<Record> resultsForTable = firstPage.resultsForTable(table);
assertThat(resultsForTable.size()).isEqualTo(2);
BatchGetResultPage secondPage = iterator.next();
assertThat(secondPage.resultsForTable(table).size()).isEqualTo(1);
assertThat(iterator).isExhausted();
}
Aggregations