Package com.cloudinary

Examples of com.cloudinary.Transformation


        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);
    }
View Full Code Here


    @Test
    public void test08DeleteDerived() throws Exception {
        // should allow deleting derived resource
        cloudinary.uploader().upload("src/test/resources/logo.png", Cloudinary.asMap(
                "public_id", "api_test3",
                "eager", Collections.singletonList(new Transformation().width(101).crop("scale"))
                ));
        Map resource = api.resource("api_test3", Cloudinary.emptyMap());
        assertNotNull(resource);
        List<Map> derived = (List<Map>) resource.get("derived");
        assertEquals(derived.size(), 1);
View Full Code Here

    @Test
    public void test13TransformationMetadata() throws Exception {
        // should allow getting transformation metadata
        Map transformation = api.transformation("c_scale,w_100", Cloudinary.emptyMap());
        assertNotNull(transformation);
        assertEquals(new Transformation((List<Map>) transformation.get("info")).generate(), new Transformation().crop("scale").width(100)
                .generate());
    }
View Full Code Here

    }

    @Test
    public void test15TransformationCreate() throws Exception {
        // should allow creating named transformation
        api.createTransformation("api_test_transformation", new Transformation().crop("scale").width(102).generate(), Cloudinary.emptyMap());
        Map transformation = api.transformation("api_test_transformation", Cloudinary.emptyMap());
        assertNotNull(transformation);
        assertEquals(transformation.get("allowed_for_strict"), true);
        assertEquals(new Transformation((List<Map>) transformation.get("info")).generate(), new Transformation().crop("scale").width(102)
                .generate());
        assertEquals(transformation.get("used"), false);
    }
View Full Code Here

    }

    @Test
    public void test15aTransformationUnsafeUpdate() throws Exception {
        // should allow unsafe update of named transformation
        api.createTransformation("api_test_transformation3", new Transformation().crop("scale").width(102).generate(), Cloudinary.emptyMap());
        api.updateTransformation("api_test_transformation3", Cloudinary.asMap("unsafe_update", new Transformation().crop("scale").width(103).generate()), Cloudinary.emptyMap());
        Map transformation = api.transformation("api_test_transformation3", Cloudinary.emptyMap());
        assertNotNull(transformation);
        assertEquals(new Transformation((List<Map>) transformation.get("info")).generate(), new Transformation().crop("scale").width(103)
                .generate());
        assertEquals(transformation.get("used"), false);
    }
View Full Code Here

    }

    @Test
    public void test16aTransformationDelete() throws Exception {
        // should allow deleting named transformation
        api.createTransformation("api_test_transformation2", new Transformation().crop("scale").width(103).generate(), Cloudinary.emptyMap());
        api.transformation("api_test_transformation2", Cloudinary.emptyMap());
        api.deleteTransformation("api_test_transformation2", Cloudinary.emptyMap());
    }
View Full Code Here

    // This test must be last because it deletes (potentially) all dependent transformations which some tests rely on.
    // Add @Test if you really want to test it - This test deletes derived resources!
    public void testDeleteAllResources() throws Exception {
        // should allow deleting all resources
        cloudinary.uploader().upload("src/test/resources/logo.png", Cloudinary.asMap("public_id", "api_test5", "eager", Collections.singletonList(new Transformation().crop("scale").width(2.0))));
        Map result = api.resource("api_test5", Cloudinary.emptyMap());
        assertEquals(1, ((org.json.simple.JSONArray) result.get("derived")).size());
        api.deleteAllResources(Cloudinary.asMap("keep_original", true));
        result = api.resource("api_test5", Cloudinary.emptyMap());
        //assertEquals(0, ((org.json.simple.JSONArray) result.get("derived")).size());
View Full Code Here

  @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());
View Full Code Here

    assertEquals("http://res.cloudinary.com/test123/image/upload/test.jpg", result);
  }

  @Test
  public void testCrop() {
    Transformation transformation = new Transformation().width(100).height(101);
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/h_101,w_100/test", result);
    assertEquals("101", transformation.getHtmlHeight().toString());
    assertEquals("100", transformation.getHtmlWidth().toString());
    transformation = new Transformation().width(100).height(101).crop("crop");
    result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/c_crop,h_101,w_100/test", result);
  }
View Full Code Here

  }

  @Test
  public void testVariousOptions() {
    // should use x, y, radius, prefix, gravity and quality from options
    Transformation transformation = new Transformation().x(1).y(2).radius(3).gravity("center").quality(0.4).prefix("a");
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/g_center,p_a,q_0.4,r_3,x_1,y_2/test", result);
  }
View Full Code Here

TOP

Related Classes of com.cloudinary.Transformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.