99import org .junit .runners .MethodSorters ;
1010
1111import java .util .List ;
12+ import java .util .concurrent .CountDownLatch ;
1213
1314import static junit .framework .Assert .assertTrue ;
1415import static junit .framework .TestCase .assertEquals ;
16+ import static junit .framework .TestCase .assertNotNull ;
1517
1618import androidx .test .InstrumentationRegistry ;
1719import androidx .test .core .app .ApplicationProvider ;
@@ -22,6 +24,8 @@ public class AssetTestCase {
2224 private final String TAG = AssetTestCase .class .getSimpleName ();
2325 private static String assetUid = BuildConfig .assetUID ;
2426 private static Stack stack ;
27+ private static CountDownLatch latch ;
28+
2529
2630 @ BeforeClass
2731 public static void oneTimeSetUp () throws Exception {
@@ -191,4 +195,75 @@ public void test_GCP_NA() throws Exception {
191195 stack = Contentstack .stack (appContext , DEFAULT_API_KEY , DEFAULT_DELIVERY_TOKEN , DEFAULT_ENV , config );
192196 }
193197
198+ @ Test
199+ public void test_I_fetch_asset_by_title () {
200+ final AssetLibrary assetLibrary = stack .assetLibrary ().where ("title" , "iot-icon.png" );
201+ assetLibrary .fetchAll (new FetchAssetsCallback () {
202+ @ Override
203+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
204+ if (error == null ) {
205+ for (Asset asset : assets ) {
206+ Log .d ("RESULT:" , "resp" + asset .json );
207+ }
208+ }
209+ }
210+ });
211+ }
212+
213+ @ Test
214+ public void test_J_fetch_asset_by_tags () {
215+ final AssetLibrary assetLibrary = stack .assetLibrary ().where ("tags" ,"tag1" );
216+ assetLibrary .fetchAll (new FetchAssetsCallback () {
217+ @ Override
218+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
219+ if (error == null ) {
220+ for ( Asset asset : assets ){
221+ Log .d ("RESULT:" , "resp" + asset .json );
222+ }
223+ assertTrue (assets .size ()>0 );
224+ }
225+ }
226+ });
227+ }
228+
229+ @ Test
230+ public void test_K_fetch_asset_by_description () {
231+ final AssetLibrary assetLibrary = stack .assetLibrary ().where ("description" ,"Page1" );
232+ assetLibrary .fetchAll (new FetchAssetsCallback () {
233+ @ Override
234+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
235+ for (Asset asset : assets ){
236+ Log .d ("RESULT:" , "resp" + asset .toJSON ());
237+ }
238+ assertTrue (assets .size ()>0 );
239+ }
240+ });
241+ }
242+
243+ @ Test
244+ public void test_L_fetch_asset_invalid () {
245+ final AssetLibrary assetLibrary = stack .assetLibrary ().where ("title" ,null );
246+ assetLibrary .fetchAll (new FetchAssetsCallback () {
247+ @ Override
248+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
249+ Log .e ("RESULT:" , "ERROR:" + error .errorMessage );
250+ }
251+ });
252+
253+ }
254+
255+ @ Test
256+ public void test_M_fetch_asset_empty_title () {
257+ final AssetLibrary assetLibrary = stack .assetLibrary ().where ("title" ,"" );
258+ assetLibrary .fetchAll (new FetchAssetsCallback () {
259+ @ Override
260+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
261+ for (Asset asset : assets ){
262+ Log .d ("RESULT:" , "resp: " + asset .toJSON ());
263+ }
264+ assertEquals (0 , assets .size ());
265+ }
266+ });
267+ }
268+
194269}
0 commit comments