@@ -266,6 +266,47 @@ void shouldFindDocumentIn() {
266266 assertEquals (entities , entityManager .select (query ).collect (Collectors .toList ()));
267267 }
268268
269+ @ Test
270+ void shouldFindBetween () {
271+ var deleteQuery = delete ().from (COLLECTION_NAME ).where ("type" ).eq ("V" ).build ();
272+ entityManager .delete (deleteQuery );
273+ Iterable <CommunicationEntity > entitiesSaved = entityManager .insert (getEntitiesWithValues ());
274+
275+ var query = select ().from (COLLECTION_NAME )
276+ .where ("age" ).between (22 , 23 )
277+ .build ();
278+
279+ var result = entityManager .select (query ).toList ();
280+
281+ SoftAssertions .assertSoftly (softly -> {
282+ softly .assertThat (result ).hasSize (2 );
283+ softly .assertThat (result ).map (e -> e .find ("age" ).orElseThrow ().get (Integer .class )).contains (22 , 23 );
284+ softly .assertThat (result ).map (e -> e .find ("age" ).orElseThrow ().get (Integer .class )).doesNotContain (25 );
285+ });
286+ }
287+
288+ @ Test
289+ void shouldFindBetween2 () {
290+ var deleteQuery = delete ().from (COLLECTION_NAME ).where ("type" ).eq ("V" ).build ();
291+ entityManager .delete (deleteQuery );
292+ Iterable <CommunicationEntity > entitiesSaved = entityManager .insert (getEntitiesWithValues ());
293+
294+ var query = select ().from (COLLECTION_NAME )
295+ .where ("age" ).between (22 , 23 )
296+ .and ("type" ).eq ("V" )
297+ .build ();
298+
299+ var result = entityManager .select (query ).toList ();
300+
301+ SoftAssertions .assertSoftly (softly -> {
302+ softly .assertThat (result ).hasSize (2 );
303+ softly .assertThat (result ).map (e -> e .find ("age" ).orElseThrow ().get (Integer .class )).contains (22 , 23 );
304+ softly .assertThat (result ).map (e -> e .find ("age" ).orElseThrow ().get (Integer .class )).doesNotContain (25 );
305+ });
306+ }
307+
308+
309+
269310 @ Test
270311 void shouldFindDocumentStart () {
271312 DeleteQuery deleteQuery = delete ().from (COLLECTION_NAME ).where ("type" ).eq ("V" ).build ();
@@ -440,7 +481,7 @@ void shouldCreateEntityByteArray() {
440481 entityManager .insert (entity );
441482
442483 List <CommunicationEntity > entities = entityManager .select (select ().from ("download" )
443- .where ("_id" ).eq (id ).build ()).collect ( Collectors . toList () );
484+ .where ("_id" ).eq (id ).build ()).toList ();
444485
445486 assertEquals (1 , entities .size ());
446487 CommunicationEntity documentEntity = entities .get (0 );
@@ -481,6 +522,7 @@ void shouldConvertFromListDocumentList() {
481522 assertDoesNotThrow (() -> entityManager .insert (entity ));
482523 }
483524
525+ @ SuppressWarnings ("unchecked" )
484526 @ Test
485527 void shouldRetrieveListDocumentList () {
486528 CommunicationEntity entity = entityManager .insert (createDocumentList ());
@@ -565,6 +607,7 @@ void shouldUpdateNull(){
565607 });
566608 }
567609
610+
568611 private CommunicationEntity createDocumentList () {
569612 CommunicationEntity entity = CommunicationEntity .of ("AppointmentBook" );
570613 entity .add (Element .of ("_id" , new Random ().nextInt ()));
@@ -594,23 +637,24 @@ private CommunicationEntity getEntity() {
594637 }
595638
596639 private List <CommunicationEntity > getEntitiesWithValues () {
597- CommunicationEntity lucas = CommunicationEntity .of (COLLECTION_NAME );
640+ var lucas = CommunicationEntity .of (COLLECTION_NAME );
598641 lucas .add (Element .of ("name" , "Lucas" ));
599642 lucas .add (Element .of ("age" , 22 ));
600643 lucas .add (Element .of ("location" , "BR" ));
601644 lucas .add (Element .of ("type" , "V" ));
602645
603- CommunicationEntity otavio = CommunicationEntity .of (COLLECTION_NAME );
646+ var luna = CommunicationEntity .of (COLLECTION_NAME );
647+ luna .add (Element .of ("name" , "Luna" ));
648+ luna .add (Element .of ("age" , 23 ));
649+ luna .add (Element .of ("location" , "US" ));
650+ luna .add (Element .of ("type" , "V" ));
651+
652+ var otavio = CommunicationEntity .of (COLLECTION_NAME );
604653 otavio .add (Element .of ("name" , "Otavio" ));
605654 otavio .add (Element .of ("age" , 25 ));
606655 otavio .add (Element .of ("location" , "BR" ));
607656 otavio .add (Element .of ("type" , "V" ));
608657
609- CommunicationEntity luna = CommunicationEntity .of (COLLECTION_NAME );
610- luna .add (Element .of ("name" , "Luna" ));
611- luna .add (Element .of ("age" , 23 ));
612- luna .add (Element .of ("location" , "US" ));
613- luna .add (Element .of ("type" , "V" ));
614658
615659 return asList (lucas , otavio , luna );
616660 }
0 commit comments