use of software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record in project aws-sdk-java-v2 by aws.
the class AsyncBatchGetItemTest method successfulResponseWithoutUnprocessedKeys_viaFlattenedItems_NoNextPage.
@Test
public void successfulResponseWithoutUnprocessedKeys_viaFlattenedItems_NoNextPage() {
stubSuccessfulResponse();
BatchGetResultPagePublisher publisher = enhancedClient.batchGetItem(r -> r.readBatches(ReadBatch.builder(Record.class).mappedTableResource(table).build()));
List<Record> records = drainPublisher(publisher.resultsForTable(table), 3);
assertThat(records.size()).isEqualTo(3);
}
use of software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record in project aws-sdk-java-v2 by aws.
the class BatchGetItemTest method setup.
@Before
public void setup() {
DynamoDbClient dynamoDbClient = DynamoDbClient.builder().region(Region.US_WEST_2).credentialsProvider(() -> AwsBasicCredentials.create("foo", "bar")).endpointOverride(URI.create("http://localhost:" + wireMock.port())).endpointDiscoveryEnabled(false).build();
enhancedClient = DynamoDbEnhancedClient.builder().dynamoDbClient(dynamoDbClient).build();
StaticTableSchema<Record> tableSchema = StaticTableSchema.builder(Record.class).newItemSupplier(Record::new).addAttribute(Integer.class, a -> a.name("id").getter(Record::getId).setter(Record::setId).tags(primaryPartitionKey())).build();
table = enhancedClient.table("table", tableSchema);
}
use of software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record 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.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record in project aws-sdk-java-v2 by aws.
the class AsyncBatchGetItemTest method responseWithUnprocessedKeys_iterateItems_shouldFetchUnprocessedKeys.
@Test
public void responseWithUnprocessedKeys_iterateItems_shouldFetchUnprocessedKeys() throws InterruptedException {
stubResponseWithUnprocessedKeys();
BatchGetResultPagePublisher publisher = enhancedClient.batchGetItem(r -> r.readBatches(ReadBatch.builder(Record.class).mappedTableResource(table).build()));
List<Record> records = drainPublisher(publisher.resultsForTable(table), 3);
assertThat(records.size()).isEqualTo(3);
}
use of software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record in project aws-sdk-java-v2 by aws.
the class AsyncBatchGetItemTest method setup.
@Before
public void setup() {
DynamoDbAsyncClient dynamoDbClient = DynamoDbAsyncClient.builder().region(Region.US_WEST_2).credentialsProvider(() -> AwsBasicCredentials.create("foo", "bar")).endpointOverride(URI.create("http://localhost:" + wireMock.port())).endpointDiscoveryEnabled(false).build();
enhancedClient = DynamoDbEnhancedAsyncClient.builder().dynamoDbClient(dynamoDbClient).build();
StaticTableSchema<Record> tableSchema = StaticTableSchema.builder(Record.class).newItemSupplier(Record::new).addAttribute(Integer.class, a -> a.name("id").getter(Record::getId).setter(Record::setId).tags(primaryPartitionKey())).build();
table = enhancedClient.table("table", tableSchema);
}
Aggregations