Search in sources :

Example 1 with ReturnItemCollectionMetrics

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

the class AsyncDeleteItemWithResponseIntegrationTest method delete_returnItemCollectionMetrics_set_itemCollectionMetricsNotNull.

@Test
public void delete_returnItemCollectionMetrics_set_itemCollectionMetricsNotNull() {
    Key key = Key.builder().partitionValue(1).sortValue(10).build();
    DeleteItemEnhancedResponse<Record> response = mappedTable.deleteItemWithResponse(r -> r.key(key).returnItemCollectionMetrics(ReturnItemCollectionMetrics.SIZE)).join();
    assertThat(response.itemCollectionMetrics()).isNotNull();
}
Also used : AfterClass(org.junit.AfterClass) StaticAttributeTags.primarySortKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primarySortKey) BeforeClass(org.junit.BeforeClass) ProjectionType(software.amazon.awssdk.services.dynamodb.model.ProjectionType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DynamoDbAsyncClient(software.amazon.awssdk.services.dynamodb.DynamoDbAsyncClient) ReturnConsumedCapacity(software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity) StaticAttributeTags.secondaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondaryPartitionKey) Test(org.junit.Test) EnhancedLocalSecondaryIndex(software.amazon.awssdk.enhanced.dynamodb.model.EnhancedLocalSecondaryIndex) DeleteItemEnhancedResponse(software.amazon.awssdk.enhanced.dynamodb.model.DeleteItemEnhancedResponse) Objects(java.util.Objects) StaticAttributeTags.primaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey) Projection(software.amazon.awssdk.services.dynamodb.model.Projection) StaticAttributeTags.secondarySortKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondarySortKey) StaticTableSchema(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticTableSchema) ReturnItemCollectionMetrics(software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics) StaticAttributeTags.primarySortKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primarySortKey) StaticAttributeTags.secondaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondaryPartitionKey) StaticAttributeTags.primaryPartitionKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.primaryPartitionKey) StaticAttributeTags.secondarySortKey(software.amazon.awssdk.enhanced.dynamodb.mapper.StaticAttributeTags.secondarySortKey) Test(org.junit.Test)

Example 2 with ReturnItemCollectionMetrics

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

the class UpdateItemEnhancedRequestTest method toBuilder.

@Test
public void toBuilder() {
    FakeItem fakeItem = createUniqueFakeItem();
    Expression conditionExpression = Expression.builder().expression("#key = :value OR #key1 = :value1").putExpressionName("#key", "attribute").putExpressionName("#key1", "attribute3").putExpressionValue(":value", stringValue("wrong")).putExpressionValue(":value1", stringValue("three")).build();
    ReturnConsumedCapacity returnConsumedCapacity = ReturnConsumedCapacity.TOTAL;
    ReturnItemCollectionMetrics returnItemCollectionMetrics = ReturnItemCollectionMetrics.SIZE;
    UpdateItemEnhancedRequest<FakeItem> builtObject = UpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).ignoreNulls(true).conditionExpression(conditionExpression).returnConsumedCapacity(returnConsumedCapacity).returnItemCollectionMetrics(returnItemCollectionMetrics).build();
    UpdateItemEnhancedRequest<FakeItem> copiedObject = builtObject.toBuilder().build();
    assertThat(copiedObject, is(builtObject));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnConsumedCapacity(software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) ReturnItemCollectionMetrics(software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics) Test(org.junit.Test)

Example 3 with ReturnItemCollectionMetrics

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

the class PutItemEnhancedRequestTest method builder_maximal.

@Test
public void builder_maximal() {
    FakeItem fakeItem = createUniqueFakeItem();
    Expression conditionExpression = Expression.builder().expression("#key = :value OR #key1 = :value1").putExpressionName("#key", "attribute").putExpressionName("#key1", "attribute3").putExpressionValue(":value", stringValue("wrong")).putExpressionValue(":value1", stringValue("three")).build();
    ReturnValue returnValues = ReturnValue.ALL_OLD;
    ReturnConsumedCapacity returnConsumedCapacity = ReturnConsumedCapacity.INDEXES;
    ReturnItemCollectionMetrics returnItemCollectionMetrics = ReturnItemCollectionMetrics.SIZE;
    PutItemEnhancedRequest<FakeItem> builtObject = PutItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).conditionExpression(conditionExpression).returnValues(returnValues).returnConsumedCapacity(returnConsumedCapacity).returnItemCollectionMetrics(returnItemCollectionMetrics).build();
    assertThat(builtObject.item(), is(fakeItem));
    assertThat(builtObject.conditionExpression(), is(conditionExpression));
    assertThat(builtObject.returnValues(), is(returnValues));
    assertThat(builtObject.returnValuesAsString(), is(returnValues.toString()));
    assertThat(builtObject.returnConsumedCapacity(), is(returnConsumedCapacity));
    assertThat(builtObject.returnConsumedCapacityAsString(), is(returnConsumedCapacity.toString()));
    assertThat(builtObject.returnItemCollectionMetrics(), is(returnItemCollectionMetrics));
    assertThat(builtObject.returnItemCollectionMetricsAsString(), is(returnItemCollectionMetrics.toString()));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnConsumedCapacity(software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity) ReturnValue(software.amazon.awssdk.services.dynamodb.model.ReturnValue) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) ReturnItemCollectionMetrics(software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics) Test(org.junit.Test)

Example 4 with ReturnItemCollectionMetrics

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

the class DeleteItemEnhancedRequestTest method builder_maximal.

@Test
public void builder_maximal() {
    Key key = Key.builder().partitionValue("key").build();
    Expression conditionExpression = Expression.builder().expression("#key = :value OR #key1 = :value1").putExpressionName("#key", "attribute").putExpressionName("#key1", "attribute3").putExpressionValue(":value", stringValue("wrong")).putExpressionValue(":value1", stringValue("three")).build();
    ReturnConsumedCapacity returnConsumedCapacity = ReturnConsumedCapacity.TOTAL;
    ReturnItemCollectionMetrics returnItemCollectionMetrics = ReturnItemCollectionMetrics.SIZE;
    DeleteItemEnhancedRequest builtObject = DeleteItemEnhancedRequest.builder().key(key).conditionExpression(conditionExpression).returnConsumedCapacity(returnConsumedCapacity).returnItemCollectionMetrics(returnItemCollectionMetrics).build();
    assertThat(builtObject.key(), is(key));
    assertThat(builtObject.conditionExpression(), is(conditionExpression));
    assertThat(builtObject.returnConsumedCapacity(), is(returnConsumedCapacity));
    assertThat(builtObject.returnConsumedCapacityAsString(), is(returnConsumedCapacity.toString()));
    assertThat(builtObject.returnItemCollectionMetrics(), is(returnItemCollectionMetrics));
    assertThat(builtObject.returnItemCollectionMetricsAsString(), is(returnItemCollectionMetrics.toString()));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnConsumedCapacity(software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity) Key(software.amazon.awssdk.enhanced.dynamodb.Key) ReturnItemCollectionMetrics(software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics) Test(org.junit.Test)

Example 5 with ReturnItemCollectionMetrics

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

the class DeleteItemEnhancedRequestTest method equals_returnItemCollectionMetricsNotEqual.

@Test
public void equals_returnItemCollectionMetricsNotEqual() {
    ReturnItemCollectionMetrics returnItemCollectionMetrics1 = ReturnItemCollectionMetrics.SIZE;
    ReturnItemCollectionMetrics returnItemCollectionMetrics2 = ReturnItemCollectionMetrics.NONE;
    DeleteItemEnhancedRequest builtObject1 = DeleteItemEnhancedRequest.builder().returnItemCollectionMetrics(returnItemCollectionMetrics1).build();
    DeleteItemEnhancedRequest builtObject2 = DeleteItemEnhancedRequest.builder().returnItemCollectionMetrics(returnItemCollectionMetrics2).build();
    assertThat(builtObject1, not(equalTo(builtObject2)));
}
Also used : ReturnItemCollectionMetrics(software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 ReturnItemCollectionMetrics (software.amazon.awssdk.services.dynamodb.model.ReturnItemCollectionMetrics)14 ReturnConsumedCapacity (software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity)11 Expression (software.amazon.awssdk.enhanced.dynamodb.Expression)10 FakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem)9 FakeItem.createUniqueFakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem)9 ReturnValue (software.amazon.awssdk.services.dynamodb.model.ReturnValue)6 HashMap (java.util.HashMap)5 AttributeValue (software.amazon.awssdk.services.dynamodb.model.AttributeValue)5 Collections (java.util.Collections)4 Collections.singletonList (java.util.Collections.singletonList)4 Map (java.util.Map)4 UUID (java.util.UUID)4 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)4 Matchers.is (org.hamcrest.Matchers.is)4 Matchers.nullValue (org.hamcrest.Matchers.nullValue)4 Matchers.sameInstance (org.hamcrest.Matchers.sameInstance)4 RunWith (org.junit.runner.RunWith)4 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)4 Mock (org.mockito.Mock)4