@@ -46,6 +46,7 @@ abstract public class AbstractApiTest extends MockableTest {
4646 public static final Transformation DELETE_TRANSFORMATION = new Transformation ().width (100 ).crop ("scale" ).overlay (new TextLayer ().text (SUFFIX + "_delete" ).fontFamily ("Arial" ).fontSize (60 ));
4747 public static final String TEST_KEY = "test-key" + SUFFIX ;
4848 public static final String API_TEST_RESTORE = "api_test_restore" + SUFFIX ;
49+ public static final Set <String > createdFolders = new HashSet <String >();
4950
5051 protected Api api ;
5152
@@ -119,6 +120,12 @@ public static void tearDownClass() {
119120 api .deleteUploadPreset (API_TEST_UPLOAD_PRESET_4 , ObjectUtils .emptyMap ());
120121 } catch (Exception ignored ) {
121122 }
123+ try {
124+ for (String folder : createdFolders ) {
125+ api .deleteFolder (folder , ObjectUtils .emptyMap ());
126+ }
127+ } catch (Exception ignored ) {
128+ }
122129
123130 }
124131
@@ -484,7 +491,8 @@ public void testListTransformationByNamed() throws Exception {
484491 } finally {
485492 try {
486493 api .deleteTransformation (name , null );
487- } catch (Exception ignored ){}
494+ } catch (Exception ignored ) {
495+ }
488496 }
489497 }
490498
@@ -653,7 +661,7 @@ public void testGetUploadPreset() throws Exception {
653661 String [] tags = {"a" , "b" , "c" };
654662 Map context = ObjectUtils .asMap ("a" , "b" , "c" , "d" );
655663 Map result = api .createUploadPreset (ObjectUtils .asMap ("unsigned" , true , "folder" , "folder" , "transformation" , EXPLICIT_TRANSFORMATION , "tags" , tags , "context" ,
656- context ,"live" ,true ));
664+ context , "live" , true ));
657665 String name = result .get ("name" ).toString ();
658666 Map preset = api .uploadPreset (name , ObjectUtils .emptyMap ());
659667 assertEquals (preset .get ("name" ), name );
@@ -693,7 +701,7 @@ public void testUpdateUploadPreset() throws Exception {
693701 String name = api .createUploadPreset (ObjectUtils .asMap ("folder" , "folder" )).get ("name" ).toString ();
694702 Map preset = api .uploadPreset (name , ObjectUtils .emptyMap ());
695703 Map settings = (Map ) preset .get ("settings" );
696- settings .putAll (ObjectUtils .asMap ("colors" , true , "unsigned" , true , "disallow_public_id" , true ,"live" ,true ));
704+ settings .putAll (ObjectUtils .asMap ("colors" , true , "unsigned" , true , "disallow_public_id" , true , "live" , true ));
697705 api .updateUploadPreset (name , settings );
698706 settings .remove ("unsigned" );
699707 preset = api .uploadPreset (name , ObjectUtils .emptyMap ());
@@ -758,6 +766,14 @@ public void testFolderApi() throws Exception {
758766 api .deleteResourcesByPrefix ("test_folder" , ObjectUtils .emptyMap ());
759767 }
760768
769+ @ Test
770+ public void testCreateFolder () throws Exception {
771+ String apTestCreateFolder = "api_test_create_folder" + "_" + SUFFIX ;
772+ createdFolders .add (apTestCreateFolder );
773+ Map result = api .createFolder ("apTestCreateFolder" , null );
774+ assertTrue ((Boolean ) result .get ("success" ));
775+ }
776+
761777 @ Test
762778 public void testRestore () throws Exception {
763779 // should support restoring resources
@@ -946,7 +962,7 @@ public void testDeleteFolder() throws Exception {
946962 Thread .sleep (5000 );
947963 api .deleteResources (Collections .singletonList (uploadResult .get ("public_id" ).toString ()), emptyMap ());
948964 ApiResponse result = api .deleteFolder (toDelete , emptyMap ());
949- assertTrue (((ArrayList )result .get ("deleted" )).contains (toDelete ));
965+ assertTrue (((ArrayList ) result .get ("deleted" )).contains (toDelete ));
950966
951967 // should throw exception (folder not found):
952968 api .deleteFolder (cloudinary .randomPublicId (), emptyMap ());
@@ -958,4 +974,4 @@ public void testCinemagraphAnalysisResource() throws Exception {
958974 ApiResponse res = api .resource (API_TEST , Collections .singletonMap ("cinemagraph_analysis" , true ));
959975 assertNotNull (res .get ("cinemagraph_analysis" ));
960976 }
961- }
977+ }
0 commit comments