99import java .lang .reflect .Field ;
1010import java .util .*;
1111
12+ import static org .hamcrest .Matchers .hasEntry ;
13+ import static org .hamcrest .Matchers .hasItem ;
14+ import static org .hamcrest .core .AllOf .allOf ;
1215import static org .junit .Assert .*;
1316import static org .junit .Assume .assumeNotNull ;
1417
@@ -19,6 +22,7 @@ abstract public class AbstractSearchTest extends MockableTest {
1922 private static final String SEARCH_TAG = "search_test_tag_" + SUFFIX ;
2023 public static final String [] UPLOAD_TAGS = {SDK_TEST_TAG , SEARCH_TAG };
2124 private static final String SEARCH_TEST = "search_test_" + SUFFIX ;
25+ private static final String SEARCH_FOLDER = "search_folder_" + SUFFIX ;
2226 private static final String SEARCH_TEST_1 = SEARCH_TEST + "_1" ;
2327 private static final String SEARCH_TEST_2 = SEARCH_TEST + "_2" ;
2428 private static String SEARCH_TEST_ASSET_ID_1 ;
@@ -44,6 +48,11 @@ public static void setUpClass() throws Exception {
4448 public static void tearDownClass () throws Exception {
4549 Cloudinary cloudinary = new Cloudinary ();
4650 cloudinary .api ().deleteResourcesByTag (SEARCH_TAG , null );
51+ try {
52+ cloudinary .api ().deleteFolder (SEARCH_FOLDER , null );
53+ } catch (Exception e ){
54+ System .err .println (e .getMessage ());
55+ }
4756 }
4857
4958 @ Before
@@ -60,6 +69,14 @@ public void shouldFindResourcesByTag() throws Exception {
6069 assertEquals (3 , resources .size ());
6170 }
6271
72+ @ Test
73+ public void shouldFindFolders () throws Exception {
74+ cloudinary .api ().createFolder (SEARCH_FOLDER , null );
75+ Map result = cloudinary .searchFolders ().expression (String .format ("name:%s" , SEARCH_FOLDER )).execute ();
76+ final List <Map > folders = (List ) result .get ("folders" );
77+ assertThat (folders , hasItem (hasEntry ("name" , SEARCH_FOLDER )));
78+ }
79+
6380 @ Test
6481 public void shouldFindResourceByPublicId () throws Exception {
6582 Map result = cloudinary .search ().expression (String .format ("public_id:%s" , SEARCH_TEST_1 )).execute ();
0 commit comments