Esempio n. 1
0
 @Test
 public void testUpdateCustomCoordinates() throws IOException, Exception {
   // should update custom coordinates
   Coordinates coordinates = new Coordinates("121,31,110,151");
   Map uploadResult =
       cloudinary.uploader().upload("src/test/resources/logo.png", Cloudinary.emptyMap());
   cloudinary
       .api()
       .update(
           uploadResult.get("public_id").toString(),
           Cloudinary.asMap("custom_coordinates", coordinates));
   Map result =
       cloudinary
           .api()
           .resource(
               uploadResult.get("public_id").toString(), Cloudinary.asMap("coordinates", true));
   long[] expected = new long[] {121L, 31L, 110L, 151L};
   Object[] actual =
       ((org.json.simple.JSONArray)
               ((org.json.simple.JSONArray) ((Map) result.get("coordinates")).get("custom"))
                   .get(0))
           .toArray();
   for (int i = 0; i < expected.length; i++) {
     assertEquals(expected[i], actual[i]);
   }
 }
Esempio n. 2
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. 3
0
 @Before
 public void setUp() {
   this.cloudinary = new Cloudinary();
   assumeNotNull(cloudinary.getStringConfig("api_secret"));
   this.api = cloudinary.api();
 }