use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest 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.BatchGetItemEnhancedRequest 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.BatchGetItemEnhancedRequest in project aws-sdk-java-v2 by aws.
the class BatchGetItemOperationTest method generateRequest_multipleBatches_multipleTableSchemas_ConflictingConsistentReadStartingWithNull.
@Test(expected = IllegalArgumentException.class)
public void generateRequest_multipleBatches_multipleTableSchemas_ConflictingConsistentReadStartingWithNull() {
BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = BatchGetItemEnhancedRequest.builder().readBatches(ReadBatch.builder(FakeItem.class).mappedTableResource(fakeItemMappedTable).addGetItem(GetItemEnhancedRequest.builder().key(FAKE_ITEM_KEYS.get(0)).consistentRead(true).build()).addGetItem(GetItemEnhancedRequest.builder().key(FAKE_ITEM_KEYS.get(1)).consistentRead(true).build()).addGetItem(GetItemEnhancedRequest.builder().key(FAKE_ITEM_KEYS.get(2)).consistentRead(true).build()).build(), ReadBatch.builder(FakeItemWithSort.class).mappedTableResource(fakeItemWithSortMappedTable).addGetItem(GetItemEnhancedRequest.builder().key(FAKESORT_ITEM_KEYS.get(0)).build()).addGetItem(GetItemEnhancedRequest.builder().key(FAKESORT_ITEM_KEYS.get(1)).consistentRead(true).build()).addGetItem(GetItemEnhancedRequest.builder().key(FAKESORT_ITEM_KEYS.get(2)).consistentRead(true).build()).build()).build();
BatchGetItemOperation operation = BatchGetItemOperation.create(batchGetItemEnhancedRequest);
operation.generateRequest(mockExtension);
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest in project aws-sdk-java-v2 by aws.
the class BatchGetItemOperationTest method getServiceCall_usingShortcutForm_makesTheRightCallAndReturnsResponse.
@Test
public void getServiceCall_usingShortcutForm_makesTheRightCallAndReturnsResponse() {
BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = BatchGetItemEnhancedRequest.builder().readBatches(ReadBatch.builder(FakeItem.class).mappedTableResource(fakeItemMappedTable).addGetItem(FAKE_ITEM_KEYS.get(0)).build()).build();
BatchGetItemOperation operation = BatchGetItemOperation.create(batchGetItemEnhancedRequest);
BatchGetItemRequest batchGetItemRequest = BatchGetItemRequest.builder().requestItems(singletonMap("test-table", KeysAndAttributes.builder().keys(singletonList(FAKE_ITEM_MAPS.get(0))).build())).build();
BatchGetItemIterable expectedResponse = mock(BatchGetItemIterable.class);
when(mockDynamoDbClient.batchGetItemPaginator(any(BatchGetItemRequest.class))).thenReturn(expectedResponse);
SdkIterable<BatchGetItemResponse> response = operation.serviceCall(mockDynamoDbClient).apply(batchGetItemRequest);
assertThat(response, sameInstance(expectedResponse));
verify(mockDynamoDbClient).batchGetItemPaginator(batchGetItemRequest);
}
use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest in project aws-sdk-java-v2 by aws.
the class BatchGetItemOperationTest method generateRequest_multipleBatches_multipleTableSchemas.
@Test
public void generateRequest_multipleBatches_multipleTableSchemas() {
BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = BatchGetItemEnhancedRequest.builder().readBatches(ReadBatch.builder(FakeItem.class).mappedTableResource(fakeItemMappedTable).addGetItem(r -> r.key(FAKE_ITEM_KEYS.get(0))).addGetItem(r -> r.key(FAKE_ITEM_KEYS.get(1))).addGetItem(r -> r.key(FAKE_ITEM_KEYS.get(2))).build(), ReadBatch.builder(FakeItemWithSort.class).mappedTableResource(fakeItemWithSortMappedTable).addGetItem(r -> r.key(FAKESORT_ITEM_KEYS.get(0))).addGetItem(r -> r.key(FAKESORT_ITEM_KEYS.get(1))).addGetItem(r -> r.key(FAKESORT_ITEM_KEYS.get(2))).build()).build();
BatchGetItemOperation operation = BatchGetItemOperation.create(batchGetItemEnhancedRequest);
BatchGetItemRequest batchGetItemRequest = operation.generateRequest(mockExtension);
KeysAndAttributes keysAndAttributes1 = batchGetItemRequest.requestItems().get(TABLE_NAME);
KeysAndAttributes keysAndAttributes2 = batchGetItemRequest.requestItems().get(TABLE_NAME_2);
assertThat(keysAndAttributes1.keys(), containsInAnyOrder(FAKE_ITEM_MAPS.subList(0, 3).toArray()));
assertThat(keysAndAttributes2.keys(), containsInAnyOrder(FAKESORT_ITEM_MAPS.subList(0, 3).toArray()));
assertThat(keysAndAttributes1.consistentRead(), is(nullValue()));
assertThat(keysAndAttributes2.consistentRead(), is(nullValue()));
verifyNoMoreInteractions(mockExtension);
}
Aggregations