use of software.amazon.awssdk.services.dynamodb.model.WriteRequest in project beam by apache.
the class DynamoDBIOWriteTest method testWritePutItemsWithPartialSuccess.
@Test
public void testWritePutItemsWithPartialSuccess() {
List<WriteRequest> writes = putRequests(Item.range(0, 10));
when(client.batchWriteItem(any(BatchWriteItemRequest.class))).thenReturn(partialWriteSuccess(writes.subList(4, 10))).thenReturn(partialWriteSuccess(writes.subList(8, 10))).thenReturn(BatchWriteItemResponse.builder().build());
pipeline.apply(// number if items to produce
Create.of(10)).apply(// 10 items in one bundle
ParDo.of(new GenerateItems())).apply("write", DynamoDBIO.<Item>write().withWriteRequestMapperFn(putRequestMapper));
PipelineResult result = pipeline.run();
result.waitUntilFinish();
verify(client, times(3)).batchWriteItem(any(BatchWriteItemRequest.class));
InOrder ordered = inOrder(client);
ordered.verify(client).batchWriteItem(argThat(matchWritesUnordered(writes)));
ordered.verify(client).batchWriteItem(argThat(matchWritesUnordered(writes.subList(4, 10))));
ordered.verify(client).batchWriteItem(argThat(matchWritesUnordered(writes.subList(8, 10))));
}
Aggregations