use of software.amazon.awssdk.enhanced.dynamodb.model.ConditionCheck in project aws-sdk-java-v2 by aws.
the class ConditionCheckTest method hashCode_maximal.
@Test
public void hashCode_maximal() {
FakeItem fakeItem = FakeItem.createUniqueFakeItem();
String returnValues = "ALL_OLD";
Expression conditionExpression = Expression.builder().expression("expression").expressionNames(singletonMap("key1", "value1")).expressionValues(singletonMap("key2", stringValue("value2"))).build();
ConditionCheck<FakeItem> builtObject = ConditionCheck.builder().key(k -> k.partitionValue(fakeItem.getId())).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
ConditionCheck<Object> copiedObject = builtObject.toBuilder().build();
assertThat(builtObject.hashCode(), equalTo(copiedObject.hashCode()));
}
use of software.amazon.awssdk.enhanced.dynamodb.model.ConditionCheck in project aws-sdk-java-v2 by aws.
the class ConditionCheckTest method equals_maximal.
@Test
public void equals_maximal() {
FakeItem fakeItem = FakeItem.createUniqueFakeItem();
String returnValues = "ALL_OLD";
Expression conditionExpression = Expression.builder().expression("expression").expressionNames(singletonMap("key1", "value1")).expressionValues(singletonMap("key2", stringValue("value2"))).build();
ConditionCheck<FakeItem> builtObject = ConditionCheck.builder().key(k -> k.partitionValue(fakeItem.getId())).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
ConditionCheck<Object> copiedObject = builtObject.toBuilder().build();
assertThat(builtObject, equalTo(copiedObject));
}
use of software.amazon.awssdk.enhanced.dynamodb.model.ConditionCheck in project aws-sdk-java-v2 by aws.
the class ConditionCheckTest method builder_maximal.
@Test
public void builder_maximal() {
FakeItem fakeItem = FakeItem.createUniqueFakeItem();
String returnValues = "ALL_OLD";
Expression conditionExpression = Expression.builder().expression("expression").expressionNames(singletonMap("key1", "value1")).expressionValues(singletonMap("key2", stringValue("value2"))).build();
ConditionCheck<FakeItem> builtObject = ConditionCheck.builder().key(k -> k.partitionValue(fakeItem.getId())).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
assertThat(builtObject.conditionExpression(), is(conditionExpression));
assertThat(builtObject.returnValuesOnConditionCheckFailure(), is(ReturnValuesOnConditionCheckFailure.ALL_OLD));
assertThat(builtObject.returnValuesOnConditionCheckFailureAsString(), is(returnValues));
}
use of software.amazon.awssdk.enhanced.dynamodb.model.ConditionCheck in project aws-sdk-java-v2 by aws.
the class ConditionCheckTest method generateTransactWriteItem.
@Test
public void generateTransactWriteItem() {
FakeItem fakeItem = FakeItem.createUniqueFakeItem();
Map<String, AttributeValue> keyMap = singletonMap("id", stringValue(fakeItem.getId()));
String returnValues = "return-values";
Expression conditionExpression = Expression.builder().expression("expression").expressionNames(singletonMap("key1", "value1")).expressionValues(singletonMap("key2", stringValue("value2"))).build();
ConditionCheck<FakeItem> operation = ConditionCheck.builder().key(k -> k.partitionValue(fakeItem.getId())).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
OperationContext context = DefaultOperationContext.create("table-name", TableMetadata.primaryIndexName());
TransactWriteItem result = operation.generateTransactWriteItem(FakeItem.getTableSchema(), context, mockDynamoDbEnhancedClientExtension);
TransactWriteItem expectedResult = TransactWriteItem.builder().conditionCheck(software.amazon.awssdk.services.dynamodb.model.ConditionCheck.builder().tableName("table-name").key(keyMap).conditionExpression(conditionExpression.expression()).expressionAttributeValues(conditionExpression.expressionValues()).expressionAttributeNames(conditionExpression.expressionNames()).returnValuesOnConditionCheckFailure(returnValues).build()).build();
assertThat(result, is(expectedResult));
verifyNoMoreInteractions(mockDynamoDbEnhancedClientExtension);
}
Aggregations