From 32bc9b0a3b9a81b4ca76b8058a8d782d35f1bc3e Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Wed, 17 Jul 2024 15:16:17 +0530 Subject: [PATCH 1/2] feat: added where method in AssetLibrary class --- .../java/com/contentstack/sdk/AssetLibrary.java | 7 +++++++ .../com/contentstack/sdk/TestAssetLibrary.java | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/com/contentstack/sdk/AssetLibrary.java b/src/main/java/com/contentstack/sdk/AssetLibrary.java index 5bb86ba8..3f54c94a 100644 --- a/src/main/java/com/contentstack/sdk/AssetLibrary.java +++ b/src/main/java/com/contentstack/sdk/AssetLibrary.java @@ -208,4 +208,11 @@ public enum ORDERBY { ASCENDING, DESCENDING } + public AssetLibrary where(String key, String value) { + JSONObject queryParams= new JSONObject(); + queryParams.put(key,value); + urlQueries.put("query", queryParams); + return this; + } + } diff --git a/src/test/java/com/contentstack/sdk/TestAssetLibrary.java b/src/test/java/com/contentstack/sdk/TestAssetLibrary.java index 937e82c0..60d7952b 100644 --- a/src/test/java/com/contentstack/sdk/TestAssetLibrary.java +++ b/src/test/java/com/contentstack/sdk/TestAssetLibrary.java @@ -2,6 +2,9 @@ import org.junit.jupiter.api.*; +import com.google.gson.JsonObject; +import org.json.*; + import java.util.List; import java.util.logging.Logger; @@ -95,4 +98,15 @@ void testIncludeOwner() { AssetLibrary assetLibrary = stack.assetLibrary().includeMetadata(); Assertions.assertFalse(assetLibrary.headers.containsKey("include_owner")); } + + @Test + void testAssetQueryOtherThanUID() { + AssetLibrary query = stack.assetLibrary().where("tags","tag1"); + query.fetchAll(new FetchAssetsCallback() { + @Override + public void onCompletion(ResponseType responseType, List assets, Error error) { + System.out.println(assets); + } + }); + } } From 695c00f7466f4ee07fd63d7a5aaeeebbab8df485 Mon Sep 17 00:00:00 2001 From: reeshika-h Date: Wed, 17 Jul 2024 15:33:17 +0530 Subject: [PATCH 2/2] change: removed unused libraries --- src/test/java/com/contentstack/sdk/TestAssetLibrary.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/java/com/contentstack/sdk/TestAssetLibrary.java b/src/test/java/com/contentstack/sdk/TestAssetLibrary.java index 60d7952b..48607e83 100644 --- a/src/test/java/com/contentstack/sdk/TestAssetLibrary.java +++ b/src/test/java/com/contentstack/sdk/TestAssetLibrary.java @@ -2,8 +2,6 @@ import org.junit.jupiter.api.*; -import com.google.gson.JsonObject; -import org.json.*; import java.util.List; import java.util.logging.Logger;