2424import org .eclipse .jnosql .communication .semistructured .Elements ;
2525import org .eclipse .jnosql .communication .semistructured .SelectQuery ;
2626import org .junit .jupiter .api .AfterEach ;
27+ import org .junit .jupiter .api .Assertions ;
2728import org .junit .jupiter .api .BeforeEach ;
2829import org .junit .jupiter .api .Test ;
2930import org .junit .jupiter .api .condition .EnabledIfSystemProperty ;
3637import java .util .Optional ;
3738import java .util .Random ;
3839import java .util .stream .Collectors ;
40+ import java .util .stream .Stream ;
3941
4042import static java .util .Arrays .asList ;
4143import static java .util .Collections .singletonMap ;
@@ -278,6 +280,35 @@ void shouldDeleteAll() {
278280 assertThat (entities ).isEmpty ();
279281 }
280282
283+
284+ @ Test
285+ void shouldIncludeLimit () {
286+ for (int index = 0 ; index < 20 ; index ++) {
287+ var entity = getEntity ();
288+ entity .add ("index" , index );
289+ entityManager .insert (entity );
290+ }
291+ var select = select ().from (COLLECTION_NAME ).orderBy ("index" ).asc ().limit (4 ).build ();
292+ var entities = entityManager .select (select ).toList ();
293+ var indexes = entities .stream ().map (e -> e .find ("index" ).orElseThrow ().get ()).toList ();
294+ org .assertj .core .api .Assertions .assertThat (indexes ).hasSize (4 ).contains (0 , 1 , 2 , 3 );
295+ DeleteQuery deleteQuery = delete ().from (COLLECTION_NAME ).build ();
296+ entityManager .delete (deleteQuery );
297+ }
298+
299+ @ Test
300+ void shouldIncludeSkipLimit () {
301+ for (int index = 0 ; index < 20 ; index ++) {
302+ var entity = getEntity ();
303+ entity .add ("index" , index );
304+ entityManager .insert (entity );
305+ }
306+ var select = select ().from (COLLECTION_NAME ).orderBy ("index" ).asc ().skip (3 ).limit (4 ).build ();
307+ var entities = entityManager .select (select ).toList ();
308+ var indexes = entities .stream ().map (e -> e .find ("index" ).orElseThrow ().get ()).toList ();
309+ org .assertj .core .api .Assertions .assertThat (indexes ).hasSize (4 ).contains (3 , 4 , 5 , 6 );
310+ }
311+
281312 private CommunicationEntity getEntity () {
282313 CommunicationEntity entity = CommunicationEntity .of (COLLECTION_NAME );
283314 Map <String , Object > map = new HashMap <>();
@@ -307,4 +338,4 @@ private CommunicationEntity createDocumentList() {
307338 return entity ;
308339 }
309340
310- }
341+ }
0 commit comments