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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations