use of software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity 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));
}
use of software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity 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()));
}
use of software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity in project aws-sdk-java-v2 by aws.
the class DeleteItemEnhancedRequestTest method hashCode_includesReturnConsumedCapacity.
@Test
public void hashCode_includesReturnConsumedCapacity() {
DeleteItemEnhancedRequest emptyRequest = DeleteItemEnhancedRequest.builder().build();
ReturnConsumedCapacity returnConsumedCapacity = ReturnConsumedCapacity.TOTAL;
DeleteItemEnhancedRequest containsKey = DeleteItemEnhancedRequest.builder().returnConsumedCapacity(returnConsumedCapacity).build();
assertThat(containsKey.hashCode(), not(equalTo(emptyRequest.hashCode())));
}
use of software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity 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()));
}
use of software.amazon.awssdk.services.dynamodb.model.ReturnConsumedCapacity in project aws-sdk-java-v2 by aws.
the class UpdateItemOperationTest method generateRequest_withReturnConsumedCapacity_knownValue_generatesCorrectRequest.
@Test
public void generateRequest_withReturnConsumedCapacity_knownValue_generatesCorrectRequest() {
FakeItem item = createUniqueFakeItem();
ReturnConsumedCapacity returnConsumedCapacity = ReturnConsumedCapacity.TOTAL;
UpdateItemOperation<FakeItem> updateItemOperation = UpdateItemOperation.create(requestFakeItem(item, b -> b.ignoreNulls(true).returnConsumedCapacity(returnConsumedCapacity)));
UpdateItemRequest request = updateItemOperation.generateRequest(FakeItem.getTableSchema(), PRIMARY_CONTEXT, null);
UpdateItemRequest expectedRequest = ddbRequest(ddbKey(item.getId()), b -> b.returnConsumedCapacity(returnConsumedCapacity));
assertThat(request, is(expectedRequest));
}
Aggregations