1212import java .io .*;
1313import java .net .HttpURLConnection ;
1414import java .net .URL ;
15+ import java .net .URLEncoder ;
1516import java .text .ParseException ;
1617import java .text .SimpleDateFormat ;
1718import java .util .*;
1819import java .util .zip .ZipInputStream ;
1920
20- import static com .cloudinary .utils .ObjectUtils .asArray ;
21- import static com .cloudinary .utils .ObjectUtils .asMap ;
21+ import static com .cloudinary .utils .ObjectUtils .*;
2222import static com .cloudinary .utils .StringUtils .isRemoteUrl ;
2323import static org .hamcrest .Matchers .*;
2424import static org .junit .Assert .*;
@@ -259,7 +259,6 @@ public void testText() throws Exception {
259259 assertTrue (((Integer ) result .get ("height" )) > 1 );
260260 }
261261
262-
263262 @ Test
264263 public void testImageUploadTag () {
265264 String tag = cloudinary .uploader ().imageUploadTag ("test-field" , asMap ("callback" , "http://localhost/cloudinary_cors.html" ), asMap ("htmlattr" , "htmlvalue" ));
@@ -271,13 +270,19 @@ public void testImageUploadTag() {
271270 assertTrue (tag .contains ("class='cloudinary-fileupload myclass'" ));
272271 }
273272
274-
275273 @ Test
276274 public void testSprite () throws Exception {
277275 final String sprite_test_tag = String .format ("sprite_test_tag_%d" , new java .util .Date ().getTime ());
278- cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String []{sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_1" + SUFFIX ));
279- cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String []{sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_2" + SUFFIX ));
280- Map result = cloudinary .uploader ().generateSprite (sprite_test_tag , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
276+ Map uploadResult1 = cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String []{sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_1" + SUFFIX ));
277+ Map uploadResult2 = cloudinary .uploader ().upload (SRC_TEST_IMAGE , asMap ("tags" , new String []{sprite_test_tag , SDK_TEST_TAG , UPLOADER_TAG }, "public_id" , "sprite_test_tag_2" + SUFFIX ));
278+
279+ String [] urls = new String []{uploadResult1 .get ("url" ).toString (), uploadResult2 .get ("url" ).toString ()};
280+
281+ Map result = cloudinary .uploader ().generateSprite (urls , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
282+ addToDeleteList ("sprite" , result .get ("public_id" ).toString ());
283+ assertEquals (2 , ((Map ) result .get ("image_infos" )).size ());
284+
285+ result = cloudinary .uploader ().generateSprite (sprite_test_tag , asMap ("tags" , Arrays .asList (SDK_TEST_TAG , UPLOADER_TAG )));
281286 addToDeleteList ("sprite" , result .get ("public_id" ).toString ());
282287 assertEquals (2 , ((Map ) result .get ("image_infos" )).size ());
283288 result = cloudinary .uploader ().generateSprite (sprite_test_tag , asMap ("transformation" , "w_100" ));
@@ -292,10 +297,19 @@ public void testSprite() throws Exception {
292297 public void testMulti () throws Exception {
293298 final String MULTI_TEST_TAG = "multi_test_tag" + SUFFIX ;
294299 final Map options = asMap ("tags" , new String []{MULTI_TEST_TAG , SDK_TEST_TAG , UPLOADER_TAG });
295- cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
296- cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
300+ Map uploadResult1 = cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
301+ Map uploadResult2 = cloudinary .uploader ().upload (SRC_TEST_IMAGE , options );
302+
303+ String [] urls = new String []{uploadResult1 .get ("url" ).toString (), uploadResult2 .get ("url" ).toString ()};
304+
305+ Map result = cloudinary .uploader ().multi (urls , asMap ("transformation" , "c_crop,w_0.5" ));
306+ addToDeleteList ("multi" , result .get ("public_id" ).toString ());
307+
308+ assertTrue (((String ) result .get ("url" )).endsWith (".gif" ));
309+ assertTrue (((String ) result .get ("url" )).contains ("w_0.5" ));
310+
297311 List <String > ids = new ArrayList <String >();
298- Map result = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , "c_crop,w_0.5" ));
312+ result = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , "c_crop,w_0.5" ));
299313 addToDeleteList ("multi" , result .get ("public_id" ).toString ());
300314 Map pdfResult = cloudinary .uploader ().multi (MULTI_TEST_TAG , asMap ("transformation" , new Transformation ().width (111 ), "format" , "pdf" ));
301315 addToDeleteList ("multi" , pdfResult .get ("public_id" ).toString ());
0 commit comments