use of software.amazon.awssdk.services.dynamodb.model.ReturnValue 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.ReturnValue in project aws-sdk-java-v2 by aws.
the class PutItemOperationTest method generateRequest_withReturnValues_knownValue_generatesCorrectRequest.
@Test
public void generateRequest_withReturnValues_knownValue_generatesCorrectRequest() {
FakeItem fakeItem = createUniqueFakeItem();
fakeItem.setSubclassAttribute("subclass-value");
ReturnValue returnValues = ReturnValue.ALL_OLD;
PutItemOperation<FakeItem> putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).returnValues(returnValues).build());
PutItemRequest request = putItemOperation.generateRequest(FakeItem.getTableSchema(), PRIMARY_CONTEXT, null);
Map<String, AttributeValue> expectedItemMap = new HashMap<>();
expectedItemMap.put("id", AttributeValue.builder().s(fakeItem.getId()).build());
expectedItemMap.put("subclass_attribute", AttributeValue.builder().s("subclass-value").build());
PutItemRequest expectedRequest = PutItemRequest.builder().tableName(TABLE_NAME).item(expectedItemMap).returnValues(returnValues).build();
assertThat(request, is(expectedRequest));
}
use of software.amazon.awssdk.services.dynamodb.model.ReturnValue in project aws-sdk-java-v2 by aws.
the class PutItemEnhancedRequestTest 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();
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();
PutItemEnhancedRequest<FakeItem> copiedObject = builtObject.toBuilder().build();
assertThat(copiedObject, is(builtObject));
}
Aggregations