9
9
import org .junit .runners .MethodSorters ;
10
10
11
11
import java .util .List ;
12
+ import java .util .concurrent .CountDownLatch ;
12
13
13
14
import static junit .framework .Assert .assertTrue ;
14
15
import static junit .framework .TestCase .assertEquals ;
16
+ import static junit .framework .TestCase .assertNotNull ;
15
17
16
18
import androidx .test .InstrumentationRegistry ;
17
19
import androidx .test .core .app .ApplicationProvider ;
@@ -22,6 +24,8 @@ public class AssetTestCase {
22
24
private final String TAG = AssetTestCase .class .getSimpleName ();
23
25
private static String assetUid = BuildConfig .assetUID ;
24
26
private static Stack stack ;
27
+ private static CountDownLatch latch ;
28
+
25
29
26
30
@ BeforeClass
27
31
public static void oneTimeSetUp () throws Exception {
@@ -191,4 +195,75 @@ public void test_GCP_NA() throws Exception {
191
195
stack = Contentstack .stack (appContext , DEFAULT_API_KEY , DEFAULT_DELIVERY_TOKEN , DEFAULT_ENV , config );
192
196
}
193
197
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
+
194
269
}
0 commit comments