1414 */
1515package org .eclipse .jnosql .databases .oracle .communication ;
1616
17- import org .assertj .core .api .SoftAssertions ;
1817import org .eclipse .jnosql .communication .TypeReference ;
1918import org .eclipse .jnosql .communication .semistructured .CommunicationEntity ;
2019import org .eclipse .jnosql .communication .semistructured .CriteriaCondition ;
@@ -209,12 +208,12 @@ void shouldFindDocumentLesserThan() {
209208
210209 List <CommunicationEntity > entitiesFound = entityManager .select (query ).toList ();
211210
212- SoftAssertions . assertSoftly (soft -> {
211+ assertSoftly (soft -> {
213212 soft .assertThat (entitiesFound ).hasSize (1 );
214213
215214 List <String > namesFound = entitiesFound .stream ()
216215 .flatMap (d -> d .find ("name" ).stream ())
217- .map (d -> d .get (String .class ))
216+ .map (d -> d .get (String .class ))
218217 .toList ();
219218 soft .assertThat (namesFound ).contains ("Lucas" );
220219 });
@@ -252,11 +251,11 @@ void shouldFindDocumentIn() {
252251 soft .assertThat (entitiesFound ).hasSize (entities .size ());
253252 List <String > namesFound = entitiesFound .stream ()
254253 .flatMap (d -> d .find ("name" ).stream ())
255- .map (d -> d .get (String .class ))
254+ .map (d -> d .get (String .class ))
256255 .toList ();
257256 List <String > names = entities .stream ()
258257 .flatMap (d -> d .find ("name" ).stream ())
259- .map (d -> d .get (String .class ))
258+ .map (d -> d .get (String .class ))
260259 .toList ();
261260 soft .assertThat (namesFound ).containsAll (names );
262261 });
@@ -463,7 +462,7 @@ void shouldCreateDate() {
463462
464463 assertEquals (1 , entities .size ());
465464 var documentEntity = entities .get (0 );
466- assertSoftly (soft ->{
465+ assertSoftly (soft -> {
467466 soft .assertThat (id ).isEqualTo (documentEntity .find ("_id" ).orElseThrow ().get (Long .class ));
468467 soft .assertThat (now ).isEqualTo (documentEntity .find ("now" ).orElseThrow ().get (LocalDate .class ));
469468 });
@@ -498,7 +497,27 @@ void shouldCount() {
498497 assertTrue (entityManager .count (COLLECTION_NAME ) > 0 );
499498 }
500499
500+ @ Test
501+ void shouldCountWithSelectQuery () {
502+ Iterable <CommunicationEntity > entitiesSaved = entityManager .insert (getEntitiesWithValues ());
503+ List <CommunicationEntity > entities = StreamSupport .stream (entitiesSaved .spliterator (), false ).toList ();
504+
505+ assertSoftly (softly -> {
506+ softly .assertThat (entityManager .count (
507+ select ().from (COLLECTION_NAME )
508+ .where ("age" ).gt (22 )
509+ .and ("type" ).eq ("V" )
510+ .build ()
511+ )).isEqualTo (2 );
512+
513+ softly .assertThat (entityManager .count (
514+ select ().from (COLLECTION_NAME )
515+ .where ("name" ).eq ("Otavio" )
516+ .build ()
517+ )).isEqualTo (1 );
518+ });
501519
520+ }
502521
503522 @ Test
504523 void shouldSaveMap () {
@@ -532,7 +551,7 @@ void shouldInsertNull() {
532551 }
533552
534553 @ Test
535- void shouldUpdateNull (){
554+ void shouldUpdateNull () {
536555 var entity = entityManager .insert (getEntity ());
537556 entity .add (Element .of ("name" , null ));
538557 var documentEntity = entityManager .update (entity );
@@ -545,7 +564,7 @@ void shouldUpdateNull(){
545564 }
546565
547566 @ Test
548- void shouldQuery (){
567+ void shouldQuery () {
549568 entityManager .insert (getEntity ());
550569
551570 var query = "select * from database where database.content.name = 'Poliana'" ;
@@ -556,7 +575,7 @@ void shouldQuery(){
556575 }
557576
558577 @ Test
559- void shouldQueryParams (){
578+ void shouldQueryParams () {
560579 entityManager .insert (getEntity ());
561580
562581 var query = "select * from database where database.content.name = ?" ;
@@ -578,7 +597,7 @@ void shouldInsertAndRetrieveWithEnum() {
578597 var query = select ().from (COLLECTION_NAME )
579598 .where ("_id" ).eq (id ).build ();
580599 Optional <CommunicationEntity > optional = entityManager .select (query ).findFirst ();
581- SoftAssertions . assertSoftly (soft -> {
600+ assertSoftly (soft -> {
582601 soft .assertThat (optional ).isPresent ();
583602 CommunicationEntity documentEntity = optional .get ();
584603 soft .assertThat (documentEntity .find ("name" ).orElseThrow ().get (String .class )).isEqualTo ("Test Name" );
@@ -599,7 +618,7 @@ void shouldDoQueryUsingEnumAsParameter() {
599618 var query = select ().from (COLLECTION_NAME )
600619 .where ("contact_type" ).eq (ContactType .EMAIL ).build ();
601620 Optional <CommunicationEntity > optional = entityManager .select (query ).findFirst ();
602- SoftAssertions . assertSoftly (soft -> {
621+ assertSoftly (soft -> {
603622 soft .assertThat (optional ).isPresent ();
604623 CommunicationEntity documentEntity = optional .get ();
605624 soft .assertThat (documentEntity .find ("name" ).orElseThrow ().get (String .class )).isEqualTo ("Test Name" );
@@ -622,7 +641,7 @@ void shouldFindDocumentLike() {
622641
623642 List <CommunicationEntity > entitiesFound = entityManager .select (query ).collect (Collectors .toList ());
624643
625- SoftAssertions . assertSoftly (soft -> {
644+ assertSoftly (soft -> {
626645 soft .assertThat (entitiesFound ).hasSize (2 );
627646 var names = entitiesFound .stream ()
628647 .flatMap (d -> d .find ("name" ).stream ())
@@ -642,7 +661,7 @@ void shouldFindContains() {
642661 "lia" )), COLLECTION_NAME , Collections .emptyList ());
643662
644663 var result = entityManager .select (query ).toList ();
645- SoftAssertions . assertSoftly (softly -> {
664+ assertSoftly (softly -> {
646665 softly .assertThat (result ).hasSize (1 );
647666 softly .assertThat (result .get (0 ).find ("name" ).orElseThrow ().get (String .class )).isEqualTo ("Poliana" );
648667 });
@@ -657,7 +676,7 @@ void shouldStartsWith() {
657676 "Pol" )), COLLECTION_NAME , Collections .emptyList ());
658677
659678 var result = entityManager .select (query ).toList ();
660- SoftAssertions . assertSoftly (softly -> {
679+ assertSoftly (softly -> {
661680 softly .assertThat (result ).hasSize (1 );
662681 softly .assertThat (result .get (0 ).find ("name" ).orElseThrow ().get (String .class )).isEqualTo ("Poliana" );
663682 });
@@ -672,7 +691,7 @@ void shouldEndsWith() {
672691 "ana" )), COLLECTION_NAME , Collections .emptyList ());
673692
674693 var result = entityManager .select (query ).toList ();
675- SoftAssertions . assertSoftly (softly -> {
694+ assertSoftly (softly -> {
676695 softly .assertThat (result ).hasSize (1 );
677696 softly .assertThat (result .get (0 ).find ("name" ).orElseThrow ().get (String .class )).isEqualTo ("Poliana" );
678697 });
0 commit comments