Search in sources :

Example 1 with ReturnValuesOnConditionCheckFailure

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

the class TransactPutItemEnhancedRequestTest 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();
    ReturnValuesOnConditionCheckFailure returnValues = ReturnValuesOnConditionCheckFailure.ALL_OLD;
    TransactPutItemEnhancedRequest<FakeItem> builtObject = TransactPutItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
    assertThat(builtObject.item(), is(fakeItem));
    assertThat(builtObject.conditionExpression(), is(conditionExpression));
    assertThat(builtObject.returnValuesOnConditionCheckFailure(), is(returnValues));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnValuesOnConditionCheckFailure(software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Example 2 with ReturnValuesOnConditionCheckFailure

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

the class TransactPutItemEnhancedRequestTest method equals_returnValuesOnConditionCheckFailureNotEqual.

@Test
public void equals_returnValuesOnConditionCheckFailureNotEqual() {
    ReturnValuesOnConditionCheckFailure returnValues1 = ReturnValuesOnConditionCheckFailure.ALL_OLD;
    ReturnValuesOnConditionCheckFailure returnValues2 = ReturnValuesOnConditionCheckFailure.NONE;
    TransactPutItemEnhancedRequest<FakeItem> builtObject1 = TransactPutItemEnhancedRequest.builder(FakeItem.class).returnValuesOnConditionCheckFailure(returnValues1).build();
    TransactPutItemEnhancedRequest<FakeItem> builtObject2 = TransactPutItemEnhancedRequest.builder(FakeItem.class).returnValuesOnConditionCheckFailure(returnValues2).build();
    assertThat(builtObject1, not(equalTo(builtObject2)));
}
Also used : ReturnValuesOnConditionCheckFailure(software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Example 3 with ReturnValuesOnConditionCheckFailure

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

the class TransactPutItemEnhancedRequestTest method builder_returnValuesOnConditionCheckFailureNull_noNpe.

@Test
public void builder_returnValuesOnConditionCheckFailureNull_noNpe() {
    ReturnValuesOnConditionCheckFailure returnValues = null;
    TransactPutItemEnhancedRequest<FakeItem> builtObject = TransactPutItemEnhancedRequest.builder(FakeItem.class).returnValuesOnConditionCheckFailure(returnValues).build();
    assertThat(builtObject.returnValuesOnConditionCheckFailure(), is(nullValue()));
    assertThat(builtObject.returnValuesOnConditionCheckFailureAsString(), is(nullValue()));
}
Also used : ReturnValuesOnConditionCheckFailure(software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Example 4 with ReturnValuesOnConditionCheckFailure

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

the class TransactUpdateItemEnhancedRequestTest method equals_maximal.

@Test
public void equals_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();
    ReturnValuesOnConditionCheckFailure returnValues = ReturnValuesOnConditionCheckFailure.ALL_OLD;
    TransactUpdateItemEnhancedRequest<FakeItem> builtObject = TransactUpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).ignoreNulls(true).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
    TransactUpdateItemEnhancedRequest<FakeItem> copiedObject = builtObject.toBuilder().build();
    assertThat(builtObject, equalTo(copiedObject));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnValuesOnConditionCheckFailure(software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Example 5 with ReturnValuesOnConditionCheckFailure

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

the class TransactUpdateItemEnhancedRequestTest 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();
    ReturnValuesOnConditionCheckFailure returnValues = ReturnValuesOnConditionCheckFailure.ALL_OLD;
    TransactUpdateItemEnhancedRequest<FakeItem> builtObject = TransactUpdateItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).ignoreNulls(true).conditionExpression(conditionExpression).returnValuesOnConditionCheckFailure(returnValues).build();
    TransactUpdateItemEnhancedRequest<FakeItem> copiedObject = builtObject.toBuilder().build();
    assertThat(copiedObject, is(builtObject));
}
Also used : Expression(software.amazon.awssdk.enhanced.dynamodb.Expression) ReturnValuesOnConditionCheckFailure(software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure) FakeItem.createUniqueFakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem) FakeItem(software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)22 ReturnValuesOnConditionCheckFailure (software.amazon.awssdk.services.dynamodb.model.ReturnValuesOnConditionCheckFailure)22 Expression (software.amazon.awssdk.enhanced.dynamodb.Expression)16 FakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem)16 FakeItem.createUniqueFakeItem (software.amazon.awssdk.enhanced.dynamodb.functionaltests.models.FakeItem.createUniqueFakeItem)11 Key (software.amazon.awssdk.enhanced.dynamodb.Key)9 Collections.singletonMap (java.util.Collections.singletonMap)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.is (org.hamcrest.Matchers.is)5 Matchers.nullValue (org.hamcrest.Matchers.nullValue)5 AttributeValues.stringValue (software.amazon.awssdk.enhanced.dynamodb.internal.AttributeValues.stringValue)5 ConditionCheck (software.amazon.awssdk.enhanced.dynamodb.model.ConditionCheck)5 Map (java.util.Map)4 Matchers.equalTo (org.hamcrest.Matchers.equalTo)4 Matchers.not (org.hamcrest.Matchers.not)4 RunWith (org.junit.runner.RunWith)4 Mock (org.mockito.Mock)4 Mockito.verifyNoMoreInteractions (org.mockito.Mockito.verifyNoMoreInteractions)4 MockitoJUnitRunner (org.mockito.junit.MockitoJUnitRunner)4 DynamoDbEnhancedClientExtension (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension)4