示例#1
0
 @Test
 public void testGetUploadPreset() throws Exception {
   // should allow getting a single upload_preset
   String[] tags = {"a", "b", "c"};
   Map context = Cloudinary.asMap("a", "b", "c", "d");
   Transformation transformation = new Transformation();
   transformation.width(100).crop("scale");
   Map result =
       api.createUploadPreset(
           Cloudinary.asMap(
               "unsigned",
               true,
               "folder",
               "folder",
               "transformation",
               transformation,
               "tags",
               tags,
               "context",
               context));
   String name = result.get("name").toString();
   Map preset = api.uploadPreset(name, Cloudinary.emptyMap());
   assertEquals(preset.get("name"), name);
   assertEquals(Boolean.TRUE, preset.get("unsigned"));
   Map settings = (Map) preset.get("settings");
   assertEquals(settings.get("folder"), "folder");
   Map outTransformation =
       (Map) ((org.json.simple.JSONArray) settings.get("transformation")).get(0);
   assertEquals(outTransformation.get("width"), 100L);
   assertEquals(outTransformation.get("crop"), "scale");
   Object[] outTags = ((org.json.simple.JSONArray) settings.get("tags")).toArray();
   assertArrayEquals(tags, outTags);
   Map outContext = (Map) settings.get("context");
   assertEquals(context, outContext);
 }
 public Transformation(Transformation transformation) {
   this(dup(transformation.transformations));
   this.hiDPI = transformation.isHiDPI();
   this.isResponsive = transformation.isResponsive();
 }