Search in sources :

Example 1 with BatchGetResultPagePublisher

use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher in project aws-sdk-java-v2 by aws.

the class AsyncBatchGetItemTest method getRecordsFromMultipleTables_viaFlattenedItems.

@Test
public void getRecordsFromMultipleTables_viaFlattenedItems() {
    insertRecords();
    BatchGetResultPagePublisher publisher = batchGetResultPageSdkPublisherForBothTables();
    List<Record1> table1Results = drainPublisher(publisher.resultsForTable(mappedTable1), 2);
    assertThat(table1Results.size(), is(2));
    assertThat(table1Results, containsInAnyOrder(RECORDS_1.toArray()));
    List<Record2> table2Results = drainPublisher(publisher.resultsForTable(mappedTable2), 2);
    assertThat(table1Results.size(), is(2));
    assertThat(table2Results, containsInAnyOrder(RECORDS_2.toArray()));
}
Also used : BatchGetResultPagePublisher(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher) Test(org.junit.Test)

Example 2 with BatchGetResultPagePublisher

use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher 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);
}
Also used : Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) BatchGetResultPagePublisher(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher) Test(org.junit.Test)

Example 3 with BatchGetResultPagePublisher

use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher in project aws-sdk-java-v2 by aws.

the class AsyncBatchGetItemTest method notFoundRecordReturnsNull_viaFlattenedItems.

@Test
public void notFoundRecordReturnsNull_viaFlattenedItems() {
    insertRecords();
    BatchGetItemEnhancedRequest batchGetItemEnhancedRequest = requestWithNotFoundRecord();
    BatchGetResultPagePublisher publisher = enhancedAsyncClient.batchGetItem(batchGetItemEnhancedRequest);
    List<Record1> resultsForTable1 = drainPublisher(publisher.resultsForTable(mappedTable1), 1);
    assertThat(resultsForTable1.size(), is(1));
    assertThat(resultsForTable1.get(0).getId(), is(0));
    List<Record2> record2List = drainPublisher(publisher.resultsForTable(mappedTable2), 2);
    assertThat(record2List.size(), is(2));
    assertThat(record2List, containsInAnyOrder(RECORDS_2.toArray()));
}
Also used : BatchGetItemEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest) BatchGetResultPagePublisher(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher) Test(org.junit.Test)

Example 4 with BatchGetResultPagePublisher

use of software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher 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);
}
Also used : Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) BatchGetResultPagePublisher(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 BatchGetResultPagePublisher (software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher)4 Record (software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record)2 BatchGetItemEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.BatchGetItemEnhancedRequest)1