use of com.amazonaws.services.s3.model.transform.Unmarshallers.DeleteObjectsResultUnmarshaller in project aws-sdk-android by aws-amplify.
the class MultiObjectDeleteIntegrationTest method testErrorHandling.
/**
* It's difficult to trigger an actual error, so we just test the error
* parsing.
*/
@Test
public void testErrorHandling() throws Exception {
DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers.DeleteObjectsResultUnmarshaller();
DeleteObjectsResponse response = unmarshaller.unmarshall(ApplicationProvider.getApplicationContext().getResources().getAssets().open("errorResponse.xml"));
assertEquals(1, response.getDeletedObjects().size());
assertEquals(1, response.getErrors().size());
assertEquals("object1", response.getDeletedObjects().get(0).getKey());
assertEquals("123", response.getDeletedObjects().get(0).getVersionId());
assertEquals("object2", response.getErrors().get(0).getKey());
assertEquals("AccessDenied", response.getErrors().get(0).getCode());
assertEquals("Access Denied", response.getErrors().get(0).getMessage());
}
use of com.amazonaws.services.s3.model.transform.Unmarshallers.DeleteObjectsResultUnmarshaller in project aws-sdk-android by aws-amplify.
the class MultiObjectDeleteIntegrationTest method testFullServiceResponse.
/**
* Rather than recreating the conditions where a fully fleshed out response
* comes back from the service, just make sure we can parse such a response.
*/
@Test
public void testFullServiceResponse() throws Exception {
DeleteObjectsResultUnmarshaller unmarshaller = new Unmarshallers.DeleteObjectsResultUnmarshaller();
DeleteObjectsResponse response = unmarshaller.unmarshall(ApplicationProvider.getApplicationContext().getResources().getAssets().open("fullResponse.xml"));
assertEquals(2, response.getDeletedObjects().size());
assertEquals(1, response.getErrors().size());
boolean seen1 = false;
boolean seen3 = false;
for (DeletedObject obj : response.getDeletedObjects()) {
if (obj.getKey().equals("key1")) {
seen1 = true;
assertEquals("Version1", obj.getVersionId());
assertNull(obj.getDeleteMarkerVersionId());
assertFalse(obj.isDeleteMarker());
} else if (obj.getKey().equals("key3")) {
seen3 = true;
assertNull(obj.getVersionId());
assertEquals("Version3", obj.getDeleteMarkerVersionId());
assertTrue(obj.isDeleteMarker());
} else {
fail("Unexpected object found: " + obj.getKey());
}
}
assertTrue("Didn't find key1", seen1);
assertTrue("Didn't find key3", seen3);
assertEquals("key2", response.getErrors().get(0).getKey());
assertEquals("Version2", response.getErrors().get(0).getVersionId());
assertEquals("Code", response.getErrors().get(0).getCode());
assertEquals("Message", response.getErrors().get(0).getMessage());
}
Aggregations