Skip to content

Commit c287a62

Browse files
authored
Search by asset id
1 parent d5d21a8 commit c287a62

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractSearchTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ abstract public class AbstractSearchTest extends MockableTest {
2121
private static final String SEARCH_TEST = "search_test_" + SUFFIX;
2222
private static final String SEARCH_TEST_1 = SEARCH_TEST + "_1";
2323
private static final String SEARCH_TEST_2 = SEARCH_TEST + "_2";
24+
private static String SEARCH_TEST_ASSET_ID_1;
2425

2526
@BeforeClass
2627
public static void setUpClass() throws Exception {
@@ -29,7 +30,7 @@ public static void setUpClass() throws Exception {
2930
cloudinary.api().deleteResourcesByTag(SEARCH_TAG, null);
3031
cloudinary.uploader().upload(SRC_TEST_IMAGE, options);
3132
options = ObjectUtils.asMap("public_id", SEARCH_TEST_1, "tags", UPLOAD_TAGS, "context", "stage=new");
32-
cloudinary.uploader().upload(SRC_TEST_IMAGE, options);
33+
SEARCH_TEST_ASSET_ID_1 = cloudinary.uploader().upload(SRC_TEST_IMAGE, options).get("asset_id").toString();
3334
options = ObjectUtils.asMap("public_id", SEARCH_TEST_2, "tags", UPLOAD_TAGS, "context", "stage=validated");
3435
cloudinary.uploader().upload(SRC_TEST_IMAGE, options);
3536
try {
@@ -66,6 +67,13 @@ public void shouldFindResourceByPublicId() throws Exception {
6667
assertEquals(1, resources.size());
6768
}
6869

70+
@Test
71+
public void shouldFindResourceByAssetId() throws Exception {
72+
Map result = cloudinary.search().expression(String.format("asset_id:%s", SEARCH_TEST_ASSET_ID_1)).execute();
73+
List<Map> resources = (List<Map>) result.get("resources");
74+
assertEquals(1, resources.size());
75+
}
76+
6977
@Test
7078
public void shouldPaginateResourcesLimitedByTagAndOrderdByAscendingPublicId() throws Exception {
7179
List<Map> resources;

0 commit comments

Comments
 (0)