Esempio n. 1
0
 @BeforeClass
 public static void setUpClass() throws IOException {
   Cloudinary cloudinary = new Cloudinary();
   if (cloudinary.getStringConfig("api_secret") == null) {
     System.err.println("Please setup environment for Upload test to run");
     return;
   }
   Api api = cloudinary.api();
   try {
     api.deleteResources(
         Arrays.asList("api_test", "api_test1", "api_test2", "api_test3", "api_test5"),
         Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteTransformation("api_test_transformation", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteTransformation("api_test_transformation2", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteTransformation("api_test_transformation3", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteUploadPreset("api_test_upload_preset", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteUploadPreset("api_test_upload_preset2", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteUploadPreset("api_test_upload_preset3", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   try {
     api.deleteUploadPreset("api_test_upload_preset4", Cloudinary.emptyMap());
   } catch (Exception e) {
   }
   Map options =
       Cloudinary.asMap(
           "public_id",
           "api_test",
           "tags",
           new String[] {"api_test_tag", uniqueTag},
           "context",
           "key=value",
           "eager",
           Collections.singletonList(new Transformation().width(100).crop("scale")));
   cloudinary.uploader().upload("src/test/resources/logo.png", options);
   options.put("public_id", "api_test1");
   cloudinary.uploader().upload("src/test/resources/logo.png", options);
 }
Esempio n. 2
0
 @Test(expected = Api.NotFound.class)
 public void test09DeleteResources() throws Exception {
   // should allow deleting resources
   cloudinary
       .uploader()
       .upload("src/test/resources/logo.png", Cloudinary.asMap("public_id", "api_test3"));
   Map resource = api.resource("api_test3", Cloudinary.emptyMap());
   assertNotNull(resource);
   api.deleteResources(
       Arrays.asList("apit_test", "api_test2", "api_test3"), Cloudinary.emptyMap());
   api.resource("api_test3", Cloudinary.emptyMap());
 }