66import java .util .List ;
77import java .util .logging .Logger ;
88
9- import static org .junit .jupiter .api .Assertions .assertEquals ;
109
1110@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
1211@ TestMethodOrder (MethodOrderer .OrderAnnotation .class )
@@ -24,15 +23,15 @@ void testNewAssetLibrary() {
2423 public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
2524 Asset model = assets .get (0 );
2625 Assertions .assertTrue (model .getAssetUid ().startsWith ("blt" ));
27- assertEquals ("image/png" , model .getFileType ());
28- assertEquals ("13006" , model .getFileSize ());
29- assertEquals ("iot-icon.png" , model .getFileName ());
26+ Assertions . assertEquals ("image/png" , model .getFileType ());
27+ Assertions . assertEquals ("13006" , model .getFileSize ());
28+ Assertions . assertEquals ("iot-icon.png" , model .getFileName ());
3029 Assertions .assertTrue (model .getUrl ().endsWith ("iot-icon.png" ));
3130 Assertions .assertTrue (model .toJSON ().has ("created_at" ));
3231 Assertions .assertTrue (model .getCreatedBy ().startsWith ("blt" ));
33- assertEquals ("gregory" , model .getUpdateAt ().getCalendarType ());
32+ Assertions . assertEquals ("gregory" , model .getUpdateAt ().getCalendarType ());
3433 Assertions .assertTrue (model .getUpdatedBy ().startsWith ("blt" ));
35- assertEquals ("" , model .getDeletedBy ());
34+ Assertions . assertEquals ("" , model .getDeletedBy ());
3635 logger .info ("passed..." );
3736 }
3837 });
@@ -107,4 +106,60 @@ public void onCompletion(ResponseType responseType, List<Asset> assets, Error er
107106 }
108107 });
109108 }
109+
110+ @ Test
111+ void testFetchFirst10Assets () throws IllegalAccessException {
112+ AssetLibrary assetLibrary = stack .assetLibrary ();
113+ assetLibrary .skip (0 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
114+ @ Override
115+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
116+ Assertions .assertNotNull (assets , "Assets list should not be null" );
117+ Assertions .assertTrue (assets .size () <= 10 , "Assets fetched should not exceed the limit" );
118+ }
119+ });
120+ }
121+
122+ @ Test
123+ void testFetchAssetsWithSkip () throws IllegalAccessException {
124+ AssetLibrary assetLibrary = stack .assetLibrary ();
125+ assetLibrary .skip (10 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
126+ @ Override
127+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
128+ Assertions .assertNotNull (assets , "Assets list should not be null" );
129+ Assertions .assertTrue (assets .size () <= 10 , "Assets fetched should not exceed the limit" );
130+ }
131+ });
132+ }
133+
134+ @ Test
135+ void testFetchBeyondAvailableAssets () throws IllegalAccessException {
136+ AssetLibrary assetLibrary = stack .assetLibrary ();
137+ assetLibrary .skip (5000 ).limit (10 ).fetchAll (new FetchAssetsCallback () {
138+ @ Override
139+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
140+ Assertions .assertNotNull (assets , "Assets list should not be null" );
141+ Assertions .assertEquals (0 , assets .size (), "No assets should be fetched when skip exceeds available assets" );
142+ }
143+ });
144+ }
145+
146+ @ Test
147+ void testFetchAllAssetsInBatches () throws IllegalAccessException {
148+ AssetLibrary assetLibrary = stack .assetLibrary ();
149+ int limit = 50 ;
150+ int totalAssetsFetched [] = {0 };
151+
152+ for (int skip = 0 ; skip < 150 ; skip += limit ) {
153+ assetLibrary .skip (skip ).limit (limit ).fetchAll (new FetchAssetsCallback () {
154+ @ Override
155+ public void onCompletion (ResponseType responseType , List <Asset > assets , Error error ) {
156+ totalAssetsFetched [0 ] += assets .size ();
157+ Assertions .assertNotNull (assets , "Assets list should not be null" );
158+ Assertions .assertTrue (assets .size () <= limit , "Assets fetched should not exceed the limit" );
159+ Assertions .assertEquals (6 , totalAssetsFetched [0 ]);
160+ }
161+ });
162+ }
163+ }
164+
110165}
0 commit comments