@@ -24,10 +24,10 @@ void testNewAssetLibrary() {
2424 public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
2525 Asset model = assets .get (0 );
2626 Assertions .assertTrue (model .getAssetUid ().startsWith ("blt" ));
27- assertEquals ("image/png " , model .getFileType ());
28- assertEquals ("13006 " , model .getFileSize ());
29- assertEquals ("iot-icon.png " , model .getFileName ());
30- Assertions .assertTrue (model .getUrl ().endsWith ("iot-icon.png " ));
27+ assertEquals ("image/jpeg " , model .getFileType ());
28+ assertEquals ("12668 " , model .getFileSize ());
29+ assertEquals ("Jane_Austen_Headshot.jpg " , model .getFileName ());
30+ Assertions .assertTrue (model .getUrl ().endsWith ("Jane_Austen_Headshot.jpg " ));
3131 Assertions .assertTrue (model .toJSON ().has ("created_at" ));
3232 Assertions .assertTrue (model .getCreatedBy ().startsWith ("blt" ));
3333 assertEquals ("gregory" , model .getUpdateAt ().getCalendarType ());
@@ -107,4 +107,60 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
107107 }
108108 });
109109 }
110+
111+ @ Test
112+ void testFetchFirst10Assets () throws IllegalAccessException {
113+ AssetLibrary assetLibrary = stack .assetLibrary ();
114+ assetLibrary .skip (0 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
115+ @ Override
116+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
117+ Assertions .assertNotNull (assets , "Assets list should not be null" );
118+ Assertions .assertTrue (assets .size () <= 10 , "Assets fetched should not exceed the limit" );
119+ }
120+ });
121+ }
122+
123+ @ Test
124+ void testFetchAssetsWithSkip () throws IllegalAccessException {
125+ AssetLibrary assetLibrary = stack .assetLibrary ();
126+ assetLibrary .skip (10 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
127+ @ Override
128+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
129+ Assertions .assertNotNull (assets , "Assets list should not be null" );
130+ Assertions .assertTrue (assets .size () <= 10 , "Assets fetched should not exceed the limit" );
131+ }
132+ });
133+ }
134+
135+ @ Test
136+ void testFetchBeyondAvailableAssets () throws IllegalAccessException {
137+ AssetLibrary assetLibrary = stack .assetLibrary ();
138+ assetLibrary .skip (5000 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
139+ @ Override
140+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
141+ Assertions .assertNotNull (assets , "Assets list should not be null" );
142+ Assertions .assertEquals (0 , assets .size (), "No assets should be fetched when skip exceeds available assets" );
143+ }
144+ });
145+ }
146+
147+ @ Test
148+ void testFetchAllAssetsInBatches () throws IllegalAccessException {
149+ AssetLibrary assetLibrary = stack .assetLibrary ();
150+ int limit = 50 ;
151+ int totalAssetsFetched [] = {0 };
152+
153+ for (int skip = 0 ; skip < 150 ; skip += limit ) {
154+ assetLibrary .skip (skip ).limit (limit ).fetchAll (new FetchAssetsCallback () {
155+ @ Override
156+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
157+ totalAssetsFetched [0 ] += assets .size ();
158+ Assertions .assertNotNull (assets , "Assets list should not be null" );
159+ Assertions .assertTrue (assets .size () <= limit , "Assets fetched should not exceed the limit" );
160+ Assertions .assertEquals (7 , totalAssetsFetched [0 ]);
161+ }
162+ });
163+ }
164+ }
165+
110166}
0 commit comments