Ejemplo n.º 1
0
 @Test
 public void testListByModerationUpdate() throws Exception {
   // "should support listing by moderation kind and value
   Map result1 =
       cloudinary
           .uploader()
           .upload("src/test/resources/logo.png", Cloudinary.asMap("moderation", "manual"));
   Map result2 =
       cloudinary
           .uploader()
           .upload("src/test/resources/logo.png", Cloudinary.asMap("moderation", "manual"));
   Map result3 =
       cloudinary
           .uploader()
           .upload("src/test/resources/logo.png", Cloudinary.asMap("moderation", "manual"));
   api.update(
       (String) result1.get("public_id"), Cloudinary.asMap("moderation_status", "approved"));
   api.update(
       (String) result2.get("public_id"), Cloudinary.asMap("moderation_status", "rejected"));
   Map approved =
       api.resourcesByModeration("manual", "approved", Cloudinary.asMap("max_results", 1000));
   Map rejected =
       api.resourcesByModeration("manual", "rejected", Cloudinary.asMap("max_results", 1000));
   Map pending =
       api.resourcesByModeration("manual", "pending", Cloudinary.asMap("max_results", 1000));
   assertNotNull(
       findByAttr(
           (List<Map>) approved.get("resources"), "public_id", (String) result1.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) approved.get("resources"), "public_id", (String) result2.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) approved.get("resources"), "public_id", (String) result2.get("public_id")));
   assertNotNull(
       findByAttr(
           (List<Map>) rejected.get("resources"), "public_id", (String) result2.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) rejected.get("resources"), "public_id", (String) result1.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) rejected.get("resources"), "public_id", (String) result3.get("public_id")));
   assertNotNull(
       findByAttr(
           (List<Map>) pending.get("resources"), "public_id", (String) result3.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) pending.get("resources"), "public_id", (String) result1.get("public_id")));
   assertNull(
       findByAttr(
           (List<Map>) pending.get("resources"), "public_id", (String) result2.get("public_id")));
 }
Ejemplo n.º 2
0
 @Test
 public void testDetectionUpdate() {
   // should support requesting detection
   try {
     Map uploadResult =
         cloudinary.uploader().upload("src/test/resources/logo.png", Cloudinary.emptyMap());
     api.update((String) uploadResult.get("public_id"), Cloudinary.asMap("detection", "illegal"));
   } catch (Exception e) {
     assertTrue(e instanceof com.cloudinary.Api.BadRequest);
     assertTrue(e.getMessage().matches("^Illegal value(.*)"));
   }
 }
Ejemplo n.º 3
0
 @Test
 public void testManualModeration() throws Exception {
   // should support setting manual moderation status
   Map uploadResult =
       cloudinary
           .uploader()
           .upload("src/test/resources/logo.png", Cloudinary.asMap("moderation", "manual"));
   Map apiResult =
       api.update(
           (String) uploadResult.get("public_id"),
           Cloudinary.asMap("moderation_status", "approved"));
   assertEquals(
       "approved", ((Map) ((List<Map>) apiResult.get("moderation")).get(0)).get("status"));
 }