use of com.trovebox.android.common.net.UploadResponse in project mobile-android by photo.
the class TroveboxApiTest method testPhotoUploadAndDetailsEdit.
public void testPhotoUploadAndDetailsEdit() throws Exception {
File file = createTestFileForUpload();
UploadMetaData settings = new UploadMetaData();
String title = "Android";
String description = "Nice picture of an android";
String tags = "test";
boolean priv = false;
settings.setTitle(title);
settings.setDescription(description);
settings.setTags(tags);
settings.setPrivate(priv);
try {
UploadResponse resp = mApi.uploadPhoto(file, settings, null);
assertTrue(resp.isSuccess());
assertNotNull(resp.getPhoto());
try {
Photo photo = resp.getPhoto();
assertNotNull(photo);
assertTrue(photo.getTags().size() >= 1);
// assertEquals("test", resp.getPhoto().getTags().get(0));
assertEquals(title, photo.getTitle());
assertEquals(description, photo.getDescription());
assertFalse(photo.isPrivate());
title = "Android (Edited)";
description = "Nice picture of an android (Edited)";
tags = "edited";
Collection<String> tagsCollection = new ArrayList<String>();
tagsCollection.add("edited");
priv = true;
PhotoResponse photoResp = mApi.updatePhotoDetails(photo.getId(), title, description, tagsCollection, Photo.PERMISSION_PRIVATE);
photo = photoResp.getPhoto();
assertTrue(photoResp.isSuccess());
assertNotNull(photo);
assertTrue(photo.getTags().size() == 1);
assertEquals(tags, photo.getTags().get(0));
assertEquals(title, photo.getTitle());
assertEquals(description, photo.getDescription());
assertTrue(photo.isPrivate() == priv);
} finally {
// remove uploaded photo
mApi.deletePhoto(resp.getPhoto().getId());
}
} catch (Exception e) {
fail("Exception should not happen: " + e.getClass().getSimpleName() + " - " + e.getMessage());
}
file.delete();
}
use of com.trovebox.android.common.net.UploadResponse in project mobile-android by photo.
the class UploadResponseTest method testResponse.
public void testResponse() throws JSONException {
JSONObject json = JSONUtils.getJson(getInstrumentation().getContext(), R.raw.json_photo_upload);
UploadResponse response = new UploadResponse(json);
assertNotNull(response);
assertTrue(response.isSuccess());
assertNotNull(response.getPhoto());
}
Aggregations