Skip to content

Commit

Permalink
Merge pull request #124 from contentstack/enh/DX-59-fetch-asset-with-…
Browse files Browse the repository at this point in the history
…any-field

Enh/dx 59 fetch asset with any field
  • Loading branch information
reeshika-h authored Jul 19, 2024
2 parents 8a00fc2 + 695c00f commit 52c47ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/contentstack/sdk/AssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
12 changes: 12 additions & 0 deletions src/test/java/com/contentstack/sdk/TestAssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.api.*;


import java.util.List;
import java.util.logging.Logger;

Expand Down Expand Up @@ -95,4 +96,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<Asset> assets, Error error) {
System.out.println(assets);
}
});
}
}

0 comments on commit 52c47ff

Please sign in to comment.