DynamoDb batchDelete-如何测试删除某项失败

时间:2019-05-28 11:35:13

标签: amazon-dynamodb amazon-dynamodb-local

我需要能够记录在批量删除操作中尚未删除的项目。我可以获得键列表,但是如果失败,则无法测试情况。设置错误的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));
  }

0 个答案:

没有答案
相关问题