Search in sources :

Example 1 with BatchGetItemIterable

use of software.amazon.awssdk.services.dynamodb.paginators.BatchGetItemIterable 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);
}
Also used : BatchGetItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest) BatchGetItemRequest(software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest) BatchGetItemResponse(software.amazon.awssdk.services.dynamodb.model.BatchGetItemResponse) BatchGetItemIterable(software.amazon.awssdk.services.dynamodb.paginators.BatchGetItemIterable) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Example 2 with BatchGetItemIterable

use of software.amazon.awssdk.services.dynamodb.paginators.BatchGetItemIterable in project aws-sdk-java-v2 by aws.

the class BatchGetItemOperationTest method getServiceCall_usingKeyItemForm_makesTheRightCallAndReturnsResponse.

@Test
public void getServiceCall_usingKeyItemForm_makesTheRightCallAndReturnsResponse() {
    BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = BatchGetItemEnhancedRequest.builder().readBatches(ReadBatch.builder(FakeItem.class).mappedTableResource(fakeItemMappedTable).addGetItem(FAKE_ITEMS.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);
}
Also used : BatchGetItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest) BatchGetItemRequest(software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest) BatchGetItemResponse(software.amazon.awssdk.services.dynamodb.model.BatchGetItemResponse) BatchGetItemIterable(software.amazon.awssdk.services.dynamodb.paginators.BatchGetItemIterable) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem)2 FakeItem.createUniqueFakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem)2 BatchGetItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest)2 BatchGetItemRequest (software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest)2 BatchGetItemResponse (software.amazon.awssdk.services.dynamodb.model.BatchGetItemResponse)2 BatchGetItemIterable (software.amazon.awssdk.services.dynamodb.paginators.BatchGetItemIterable)2