@@ -266,6 +266,47 @@ void shouldFindDocumentIn() {
266
266
assertEquals (entities , entityManager .select (query ).collect (Collectors .toList ()));
267
267
}
268
268
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
+
269
310
@ Test
270
311
void shouldFindDocumentStart () {
271
312
DeleteQuery deleteQuery = delete ().from (COLLECTION_NAME ).where ("type" ).eq ("V" ).build ();
@@ -440,7 +481,7 @@ void shouldCreateEntityByteArray() {
440
481
entityManager .insert (entity );
441
482
442
483
List <CommunicationEntity > entities = entityManager .select (select ().from ("download" )
443
- .where ("_id" ).eq (id ).build ()).collect ( Collectors . toList () );
484
+ .where ("_id" ).eq (id ).build ()).toList ();
444
485
445
486
assertEquals (1 , entities .size ());
446
487
CommunicationEntity documentEntity = entities .get (0 );
@@ -481,6 +522,7 @@ void shouldConvertFromListDocumentList() {
481
522
assertDoesNotThrow (() -> entityManager .insert (entity ));
482
523
}
483
524
525
+ @ SuppressWarnings ("unchecked" )
484
526
@ Test
485
527
void shouldRetrieveListDocumentList () {
486
528
CommunicationEntity entity = entityManager .insert (createDocumentList ());
@@ -565,6 +607,7 @@ void shouldUpdateNull(){
565
607
});
566
608
}
567
609
610
+
568
611
private CommunicationEntity createDocumentList () {
569
612
CommunicationEntity entity = CommunicationEntity .of ("AppointmentBook" );
570
613
entity .add (Element .of ("_id" , new Random ().nextInt ()));
@@ -594,23 +637,24 @@ private CommunicationEntity getEntity() {
594
637
}
595
638
596
639
private List <CommunicationEntity > getEntitiesWithValues () {
597
- CommunicationEntity lucas = CommunicationEntity .of (COLLECTION_NAME );
640
+ var lucas = CommunicationEntity .of (COLLECTION_NAME );
598
641
lucas .add (Element .of ("name" , "Lucas" ));
599
642
lucas .add (Element .of ("age" , 22 ));
600
643
lucas .add (Element .of ("location" , "BR" ));
601
644
lucas .add (Element .of ("type" , "V" ));
602
645
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 );
604
653
otavio .add (Element .of ("name" , "Otavio" ));
605
654
otavio .add (Element .of ("age" , 25 ));
606
655
otavio .add (Element .of ("location" , "BR" ));
607
656
otavio .add (Element .of ("type" , "V" ));
608
657
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" ));
614
658
615
659
return asList (lucas , otavio , luna );
616
660
}
0 commit comments