我需要能够记录在批量删除操作中尚未删除的项目。我可以获得键列表,但是如果失败,则无法测试情况。设置错误的DynamoDBHashKey不起作用。故障列表为空。
@Override
public void deleteAll(List<Grant> grants) {
if (grants.stream().anyMatch(g -> StringUtils.isEmpty(g.getHashedRefreshToken()))) {
throw new RuntimeException("Grant's HashedRefreshToken is null");
}
final List<FailedBatch> failedBatches = mapper.batchDelete(grants);
List<Map<String, AttributeValue>> collect = failedBatches.stream()
.map(b -> b.getUnprocessedItems())
.flatMap(e -> e.values().stream())
.flatMap(e -> e.stream())
.map(e -> e.getDeleteRequest())
.map(v -> v.getKey())
.collect(Collectors.toList());
// FIXME
System.out.println("Failed items : " + collect.size());
collect.forEach(e -> System.out.println(e));
}