Search in sources :

Example 1 with TransactWriteItemsRequest

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

the class TransactWriteItemsEnhancedRequestTest method builder_passRequestToken_shouldWork.

@Test
public void builder_passRequestToken_shouldWork() {
    String token = UUID.randomUUID().toString();
    TransactWriteItemsEnhancedRequest enhancedRequest = TransactWriteItemsEnhancedRequest.builder().clientRequestToken(token).build();
    DynamoDbEnhancedClientExtension extension = ExtensionResolver.resolveExtensions(ExtensionResolver.defaultExtensions());
    TransactWriteItemsRequest request = TransactWriteItemsOperation.create(enhancedRequest).generateRequest(extension);
    assertEquals(token, request.clientRequestToken());
}
Also used : TransactWriteItemsRequest(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest) DynamoDbEnhancedClientExtension(software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension) Test(org.junit.Test)

Example 2 with TransactWriteItemsRequest

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

the class TransactWriteItemsOperationTest method getServiceCall_callsServiceAndReturnsResult.

@Test
public void getServiceCall_callsServiceAndReturnsResult() {
    TransactWriteItemsOperation operation = TransactWriteItemsOperation.create(emptyRequest());
    TransactWriteItemsRequest request = TransactWriteItemsRequest.builder().transactItems(singletonList(fakeTransactWriteItem1)).build();
    TransactWriteItemsResponse expectedResponse = TransactWriteItemsResponse.builder().build();
    when(mockDynamoDbClient.transactWriteItems(any(TransactWriteItemsRequest.class))).thenReturn(expectedResponse);
    TransactWriteItemsResponse actualResponse = operation.serviceCall(mockDynamoDbClient).apply(request);
    assertThat(actualResponse, is(sameInstance(expectedResponse)));
    verify(mockDynamoDbClient).transactWriteItems(request);
    verifyNoMoreInteractions(mockDynamoDbEnhancedClientExtension);
}
Also used : TransactWriteItemsRequest(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest) TransactWriteItemsResponse(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsResponse) Test(org.junit.Test)

Example 3 with TransactWriteItemsRequest

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

the class TransactWriteItemsOperationTest method generateRequest_multipleTransactions.

@Test
public void generateRequest_multipleTransactions() {
    TransactWriteItemsEnhancedRequest transactGetItemsEnhancedRequest = TransactWriteItemsEnhancedRequest.builder().addPutItem(fakeItemMappedTable, fakeItem1).addPutItem(fakeItemMappedTable, fakeItem2).build();
    TransactWriteItemsOperation operation = TransactWriteItemsOperation.create(transactGetItemsEnhancedRequest);
    TransactWriteItemsRequest actualRequest = operation.generateRequest(mockDynamoDbEnhancedClientExtension);
    TransactWriteItemsRequest expectedRequest = TransactWriteItemsRequest.builder().transactItems(fakeTransactWriteItem1, fakeTransactWriteItem2).build();
    assertThat(actualRequest, is(expectedRequest));
    verifyNoMoreInteractions(mockDynamoDbEnhancedClientExtension);
}
Also used : TransactWriteItemsRequest(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest) TransactWriteItemsEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.TransactWriteItemsEnhancedRequest) Test(org.junit.Test)

Example 4 with TransactWriteItemsRequest

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

the class TransactWriteItemsOperationTest method generateRequest_singleTransaction.

@Test
public void generateRequest_singleTransaction() {
    TransactWriteItemsEnhancedRequest transactGetItemsEnhancedRequest = TransactWriteItemsEnhancedRequest.builder().addPutItem(fakeItemMappedTable, fakeItem1).build();
    TransactWriteItemsOperation operation = TransactWriteItemsOperation.create(transactGetItemsEnhancedRequest);
    TransactWriteItemsRequest actualRequest = operation.generateRequest(mockDynamoDbEnhancedClientExtension);
    TransactWriteItemsRequest expectedRequest = TransactWriteItemsRequest.builder().transactItems(fakeTransactWriteItem1).build();
    assertThat(actualRequest, is(expectedRequest));
    verifyNoMoreInteractions(mockDynamoDbEnhancedClientExtension);
}
Also used : TransactWriteItemsRequest(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest) TransactWriteItemsEnhancedRequest(software.amazon.awssdk.enhanced.dynamodb.model.TransactWriteItemsEnhancedRequest) Test(org.junit.Test)

Example 5 with TransactWriteItemsRequest

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

the class TransactWriteItemsOperationTest method generateRequest_noTransactions.

@Test
public void generateRequest_noTransactions() {
    TransactWriteItemsOperation operation = TransactWriteItemsOperation.create(emptyRequest());
    TransactWriteItemsRequest actualRequest = operation.generateRequest(mockDynamoDbEnhancedClientExtension);
    TransactWriteItemsRequest expectedRequest = TransactWriteItemsRequest.builder().build();
    assertThat(actualRequest, is(expectedRequest));
    verifyNoMoreInteractions(mockDynamoDbEnhancedClientExtension);
}
Also used : TransactWriteItemsRequest(software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 TransactWriteItemsRequest (software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsRequest)6 TransactWriteItemsEnhancedRequest (software.amazon.awssdk.enhanced.dynamodb.model.TransactWriteItemsEnhancedRequest)2 Delete (com.scalar.db.api.Delete)1 DeleteIfExists (com.scalar.db.api.DeleteIfExists)1 Put (com.scalar.db.api.Put)1 PutIfNotExists (com.scalar.db.api.PutIfNotExists)1 DynamoDbEnhancedClientExtension (software.amazon.awssdk.enhanced.dynamodb.DynamoDbEnhancedClientExtension)1 TransactWriteItem (software.amazon.awssdk.services.dynamodb.model.TransactWriteItem)1 TransactWriteItemsResponse (software.amazon.awssdk.services.dynamodb.model.TransactWriteItemsResponse)1