software.amazon.awssdk.services.dynamodb.model.PutItemResponse Java Examples

The following examples show how to use software.amazon.awssdk.services.dynamodb.model.PutItemResponse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamoDBTest.java    From dynein with Apache License 2.0 6 votes vote down vote up
@Test
public void testScheduleJob_Failure() throws Exception {
  DyneinJobSpec jobSpec = getTestJobSpec(validToken, "test2");
  Schedule schedule = jobSpecToSchedule(jobSpec);
  Map<String, AttributeValue> item = DynamoDBUtils.toAttributeMap(schedule);
  CompletableFuture<PutItemResponse> ret = new CompletableFuture<>();
  Exception putException = new Exception();
  ret.completeExceptionally(putException);

  PutItemRequest putItemRequest =
      PutItemRequest.builder().tableName(tableName).item(item).build();
  when(ddbClient.putItem(putItemRequest)).thenReturn(ret);

  CompletableFuture<Void> response = scheduleManager.addJob(schedule);

  assertSame(getException(response), putException);
  verify(ddbClient, times(1)).putItem(putItemRequest);
  verifyNoMoreInteractions(ddbClient);
}
 
Example #2
Source File: PutItemOperation.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Override
public Void transformResponse(PutItemResponse response,
                              TableSchema<T> tableSchema,
                              OperationContext operationContext,
                              DynamoDbEnhancedClientExtension extension) {
    // No results are returned by this operation
    return null;
}
 
Example #3
Source File: PutItemOperationTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void getServiceCall_makesTheRightCallAndReturnsResponse() {
    FakeItem fakeItem = createUniqueFakeItem();
    PutItemOperation<FakeItem> putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class).item(fakeItem).build());
    PutItemRequest getItemRequest = PutItemRequest.builder().tableName(TABLE_NAME).build();
    PutItemResponse expectedResponse = PutItemResponse.builder().build();
    when(mockDynamoDbClient.putItem(any(PutItemRequest.class))).thenReturn(expectedResponse);

    PutItemResponse response = putItemOperation.serviceCall(mockDynamoDbClient).apply(getItemRequest);

    assertThat(response, sameInstance(expectedResponse));
    verify(mockDynamoDbClient).putItem(getItemRequest);
}
 
Example #4
Source File: PutItemOperationTest.java    From aws-sdk-java-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void transformResponse_doesNotBlowUp() {
    FakeItem fakeItem = createUniqueFakeItem();
    PutItemOperation<FakeItem> putItemOperation = PutItemOperation.create(PutItemEnhancedRequest.builder(FakeItem.class)
                                                                                                .item(fakeItem)
                                                                                                .build());
    PutItemResponse response = PutItemResponse.builder().build();

    putItemOperation.transformResponse(response, FakeItem.getTableSchema(), PRIMARY_CONTEXT, null);
}
 
Example #5
Source File: PutItemOperation.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public Function<PutItemRequest, PutItemResponse> serviceCall(DynamoDbClient dynamoDbClient) {
    return dynamoDbClient::putItem;
}
 
Example #6
Source File: PutItemOperation.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public Function<PutItemRequest, CompletableFuture<PutItemResponse>> asyncServiceCall(
    DynamoDbAsyncClient dynamoDbAsyncClient) {

    return dynamoDbAsyncClient::putItem;
}
 
Example #7
Source File: V2TestDynamoDbPutItemClient.java    From aws-sdk-java-v2 with Apache License 2.0 4 votes vote down vote up
@Override
public PutItemResponse putItem(PutItemRequest putItemRequest) {
    bh.consume(putItemRequest);
    return PUT_ITEM_RESPONSE;
}
 
Example #8
Source File: LocalDynamoDb.java    From aws-dynamodb-encryption-java with Apache License 2.0 4 votes vote down vote up
@Override
public PutItemResponse putItem(PutItemRequest putItemRequest) {
    return wrappedClient.putItem(putItemRequest);
}