Beispiel #1
0
 public void testNotPresentWhenDeleting() throws Exception {
   for (String regionId : regions) {
     BulkDeleteResponse deleteResponse =
         getApi().getBulkApi(regionId).bulkDelete(ImmutableList.of(UUID.randomUUID().toString()));
     assertEquals(deleteResponse.getDeleted(), 0);
     assertEquals(deleteResponse.getNotFound(), 1);
     assertTrue(deleteResponse.getErrors().isEmpty());
   }
 }
Beispiel #2
0
 @Test(dependsOnMethods = "testExtractArchive")
 public void testBulkDelete() throws Exception {
   for (String regionId : regions) {
     BulkDeleteResponse deleteResponse = getApi().getBulkApi(regionId).bulkDelete(paths);
     assertEquals(deleteResponse.getDeleted(), OBJECT_COUNT);
     assertEquals(deleteResponse.getNotFound(), 0);
     assertTrue(deleteResponse.getErrors().isEmpty());
     assertEquals(
         getApi().getContainerApi(regionId).get(containerName).getObjectCount(), Long.valueOf(0));
   }
 }
 @Override
 public boolean equals(Object object) {
   if (this == object) {
     return true;
   }
   if (object instanceof BulkDeleteResponse) {
     BulkDeleteResponse that = BulkDeleteResponse.class.cast(object);
     return equal(getDeleted(), that.getDeleted())
         && equal(getNotFound(), that.getNotFound())
         && equal(getErrors(), that.getErrors());
   } else {
     return false;
   }
 }
  protected void deleteAllObjectsInContainer(String regionId, final String containerName) {
    Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);

    ObjectList objects = api.getObjectApi(regionId, containerName).list(new ListContainerOptions());
    if (objects == null) {
      return;
    }
    List<String> pathsToDelete =
        Lists.transform(
            objects,
            new Function<SwiftObject, String>() {
              public String apply(SwiftObject input) {
                return containerName + "/" + input.getName();
              }
            });
    if (!pathsToDelete.isEmpty()) {
      BulkDeleteResponse response = api.getBulkApi(regionId).bulkDelete(pathsToDelete);
      checkState(
          response.getErrors().isEmpty(), "Errors deleting paths %s: %s", pathsToDelete, response);
    }
  }
 public void bulkDeleteWithoutErrors() {
   assertEquals(
       gson.fromJson(
           ""
               + "{\n"
               + "  \"Response Status\": \"200 OK\",\n"
               + "  \"Response Body\": \"\",\n"
               + "  \"Errors\": [],\n"
               + "  \"Number Not Found\": 1,\n"
               + "  \"Number Deleted\": 9\n"
               + "}",
           BulkDeleteResponse.class),
       BulkDeleteResponse.create(9, 1, ImmutableMap.<String, String>of()));
 }
 public void bulkDeleteWithErrorsAndDecodesPaths() {
   assertEquals(
       gson.fromJson(
           ""
               + "{\n"
               + "  \"Response Status\": \"400 Bad Request\",\n"
               + "  \"Response Body\": \"\",\n"
               + "  \"Errors\": [\n"
               + "    [\"/v1/12345678912345/Not%20Empty\", \"409 Conflict\"]"
               + "  ],\n"
               + "  \"Number Deleted\": 0\n"
               + "}",
           BulkDeleteResponse.class),
       BulkDeleteResponse.create(
           0, 0, ImmutableMap.of("/v1/12345678912345/Not Empty", "409 Conflict")));
 }