Search in sources :

Example 1 with StaticTableSchema

use of software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema 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);
}
Also used : DynamoDbEnhancedClient(software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClient) DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) ReadBatch(software.amazon.awssdk.enhanced.dynamodb.model.ReadBatch) DynamoDbTable(software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable) Iterator(java.util.Iterator) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) SdkIterable(software.amazon.awssdk.core.pagination.sync.SdkIterable) BatchGetTestUtils.stubResponseWithUnprocessedKeys(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubResponseWithUnprocessedKeys) Test(org.junit.Test) BatchGetResultPage(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage) Collectors(java.util.stream.Collectors) BatchGetResultPageIterable(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPageIterable) StaticAttributeTags.primaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) List(java.util.List) Rule(org.junit.Rule) BatchGetTestUtils.stubSuccessfulResponse(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubSuccessfulResponse) URI(java.net.URI) StaticTableSchema(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) Region(software.amazon.awssdk.regions.Region) Before(org.junit.Before) DynamoDbClient(software.amazon.awssdk.services.dynamodb.DynamoDbClient) Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) Before(org.junit.Before)

Example 2 with StaticTableSchema

use of software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema 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);
}
Also used : Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) ReadBatch(software.amazon.awssdk.enhanced.dynamodb.model.ReadBatch) BatchGetResultPagePublisher(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPagePublisher) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DynamoDbAsyncClient(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient) BatchGetTestUtils.stubResponseWithUnprocessedKeys(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubResponseWithUnprocessedKeys) Test(org.junit.Test) SdkPublisher(software.amazon.awssdk.core.async.SdkPublisher) DynamoDbEnhancedAsyncClient(software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedAsyncClient) BatchGetResultPage(software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage) StaticAttributeTags.primaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) List(java.util.List) Rule(org.junit.Rule) After(org.junit.After) BatchGetTestUtils.stubSuccessfulResponse(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubSuccessfulResponse) DynamoDbAsyncTable(software.amazon.awssdk.enhanced.dynamodb.DynamoDbAsyncTable) URI(java.net.URI) StaticTableSchema(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) Region(software.amazon.awssdk.regions.Region) LocalDynamoDbAsyncTestBase.drainPublisher(software.amazon.awssdk.enhanced.dynamodb.functionaltests.LocalDynamoDbAsyncTestBase.drainPublisher) Before(org.junit.Before) DynamoDbAsyncClient(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient) Record(software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record) Before(org.junit.Before)

Aggregations

WireMockRule (com.github.tomakehurst.wiremock.junit.WireMockRule)2 URI (java.net.URI)2 List (java.util.List)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Before (org.junit.Before)2 Rule (org.junit.Rule)2 Test (org.junit.Test)2 AwsBasicCredentials (software.amazon.awssdk.auth.credentials.AwsBasicCredentials)2 StaticAttributeTags.primaryPartitionKey (software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey)2 StaticTableSchema (software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema)2 Record (software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.Record)2 BatchGetTestUtils.stubResponseWithUnprocessedKeys (software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubResponseWithUnprocessedKeys)2 BatchGetTestUtils.stubSuccessfulResponse (software.amazon.awssdk.enhanced.dynamodb.mocktests.BatchGetTestUtils.stubSuccessfulResponse)2 BatchGetResultPage (software.amazon.awssdk.enhanced.dynamodb.model.BatchGetResultPage)2 ReadBatch (software.amazon.awssdk.enhanced.dynamodb.model.ReadBatch)2 Region (software.amazon.awssdk.regions.Region)2 Iterator (java.util.Iterator)1 Collectors (java.util.stream.Collectors)1 After (org.junit.After)1 SdkPublisher (software.amazon.awssdk.core.async.SdkPublisher)1