@Test public void testResourcesListingDirection() throws Exception { // should allow listing resources in both directions Map result = api.resourcesByTag(uniqueTag, Cloudinary.asMap("type", "upload", "direction", "asc")); List<Map> resources = (List<Map>) result.get("resources"); result = api.resourcesByTag(uniqueTag, Cloudinary.asMap("type", "upload", "direction", -1)); List<Map> resourcesDesc = (List<Map>) result.get("resources"); Collections.reverse(resources); assertEquals(resources, resourcesDesc); }
@Test public void test06ResourcesTag() throws Exception { // should allow listing resources by tag Map result = api.resourcesByTag("api_test_tag", Cloudinary.asMap("tags", true, "context", true)); Map resource = findByAttr((List<Map>) result.get("resources"), "public_id", "api_test"); assertNotNull(resource); resource = findByAttr( (List<Map>) result.get("resources"), "context", Cloudinary.asMap("custom", Cloudinary.asMap("key", "value"))); assertNotNull(resource); List<Map> resources = (List<Map>) result.get("resources"); boolean found = false; for (Map r : resources) { org.json.simple.JSONArray tags = (org.json.simple.JSONArray) r.get("tags"); found = found || tags.contains("api_test_tag"); } assertTrue(found); }