use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage in project aws-sdk-java-v2 by aws.
the class BatchGetItemTest method notFoundRecordIgnored.
@Test
public void notFoundRecordIgnored() {
insertRecords();
BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = batchGetItemEnhancedRequestWithNotFoundRecord();
SdkIterable<BatchGetResultPage> results = enhancedClient.batchGetItem(batchGetItemEnhancedRequest);
assertThat(results.stream().count(), is(1L));
results.iterator().forEachRemaining((page) -> {
List<Record1> mappedTable1Results = page.resultsForTable(mappedTable1);
assertThat(mappedTable1Results.size(), is(1));
assertThat(mappedTable1Results.get(0).id, is(0));
assertThat(page.resultsForTable(mappedTable2).size(), is(2));
});
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage in project aws-sdk-java-v2 by aws.
the class AsyncBatchGetItemTest method notFoundRecordReturnsNull.
@Test
public void notFoundRecordReturnsNull() {
insertRecords();
BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = requestWithNotFoundRecord();
SdkPublisher<BatchGetResultPage> publisher = enhancedAsyncClient.batchGetItem(batchGetItemEnhancedRequest);
List<BatchGetResultPage> results = drainPublisher(publisher, 1);
assertThat(results.size(), is(1));
BatchGetResultPage page = results.get(0);
List<Record1> record1List = page.resultsForTable(mappedTable1);
assertThat(record1List.size(), is(1));
assertThat(record1List.get(0).getId(), is(0));
List<Record2> record2List = page.resultsForTable(mappedTable2);
assertThat(record2List.size(), is(2));
assertThat(record2List, containsInAnyOrder(RECORDS_2.get(0), RECORDS_2.get(1)));
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage in project aws-sdk-java-v2 by aws.
the class AsyncBatchGetItemTest method getRecordsFromMultipleTables.
@Test
public void getRecordsFromMultipleTables() {
insertRecords();
SdkPublisher<BatchGetResultPage> publisher = batchGetResultPageSdkPublisherForBothTables();
List<BatchGetResultPage> results = drainPublisher(publisher, 1);
assertThat(results.size(), is(1));
BatchGetResultPage page = results.get(0);
List<Record1> record1List = page.resultsForTable(mappedTable1);
assertThat(record1List.size(), is(2));
assertThat(record1List, containsInAnyOrder(RECORDS_1.get(0), RECORDS_1.get(1)));
List<Record2> record2List = page.resultsForTable(mappedTable2);
assertThat(record2List.size(), is(2));
assertThat(record2List, containsInAnyOrder(RECORDS_2.get(0), RECORDS_2.get(1)));
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage in project aws-sdk-java-v2 by aws.
the class BatchGetItemOperationTest method transformResponse_multipleTables_multipleItems_no_unprocessedKeys.
@Test
public void transformResponse_multipleTables_multipleItems_no_unprocessedKeys() {
BatchGetItemResponse fakeResponse = BatchGetItemResponse.builder().build();
BatchGetItemOperation operation = BatchGetItemOperation.create(emptyRequest());
BatchGetResultPage resultsPage = operation.transformResponse(fakeResponse, null);
List<Key> fakeItemResults1 = resultsPage.unprocessedKeysForTable(fakeItemMappedTable);
List<Key> fakeItemResults2 = resultsPage.unprocessedKeysForTable(fakeItemWithSortMappedTable);
assertThat(fakeItemResults1, empty());
assertThat(fakeItemResults2, empty());
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage in project aws-sdk-java-v2 by aws.
the class BatchGetItemOperationTest method transformResponse_multipleTables_multipleItems_unprocessedKeys.
@Test
public void transformResponse_multipleTables_multipleItems_unprocessedKeys() {
KeysAndAttributes keysAndAttributes1 = KeysAndAttributes.builder().keys(Arrays.asList(FAKE_ITEM_MAPS.get(0), FAKE_ITEM_MAPS.get(1))).build();
KeysAndAttributes keysAndAttributes2 = KeysAndAttributes.builder().keys(Collections.singletonList(FAKESORT_ITEM_MAPS.get(0))).build();
Map<String, KeysAndAttributes> keysAndAttributesMap = new HashMap<>();
keysAndAttributesMap.put(TABLE_NAME, keysAndAttributes1);
keysAndAttributesMap.put(TABLE_NAME_2, keysAndAttributes2);
BatchGetItemResponse fakeResponse = BatchGetItemResponse.builder().unprocessedKeys(keysAndAttributesMap).build();
BatchGetItemOperation operation = BatchGetItemOperation.create(emptyRequest());
BatchGetResultPage resultsPage = operation.transformResponse(fakeResponse, null);
List<Key> fakeItemResults1 = resultsPage.unprocessedKeysForTable(fakeItemMappedTable);
List<Key> fakeItemResults2 = resultsPage.unprocessedKeysForTable(fakeItemWithSortMappedTable);
assertThat(fakeItemResults1, containsInAnyOrder(FAKE_ITEM_KEYS.get(0), FAKE_ITEM_KEYS.get(1)));
assertThat(fakeItemResults2, containsInAnyOrder(FAKESORT_ITEM_KEYS.get(0)));
}
Aggregations