19
19
import static com .google .firebase .firestore .pipeline .Expr .and ;
20
20
import static com .google .firebase .firestore .pipeline .Expr .arrayContains ;
21
21
import static com .google .firebase .firestore .pipeline .Expr .arrayContainsAny ;
22
+ import static com .google .firebase .firestore .pipeline .Expr .constant ;
22
23
import static com .google .firebase .firestore .pipeline .Expr .cosineDistance ;
23
24
import static com .google .firebase .firestore .pipeline .Expr .endsWith ;
24
25
import static com .google .firebase .firestore .pipeline .Expr .eq ;
37
38
import static com .google .firebase .firestore .pipeline .Expr .subtract ;
38
39
import static com .google .firebase .firestore .pipeline .Expr .vector ;
39
40
import static com .google .firebase .firestore .pipeline .Ordering .ascending ;
41
+ import static com .google .firebase .firestore .testutil .IntegrationTestUtil .isRunningAgainstEmulator ;
40
42
import static com .google .firebase .firestore .testutil .IntegrationTestUtil .waitFor ;
41
43
42
44
import androidx .test .ext .junit .runners .AndroidJUnit4 ;
47
49
import com .google .firebase .firestore .pipeline .AggregateFunction ;
48
50
import com .google .firebase .firestore .pipeline .AggregateStage ;
49
51
import com .google .firebase .firestore .pipeline .Expr ;
52
+ import com .google .firebase .firestore .pipeline .Field ;
50
53
import com .google .firebase .firestore .pipeline .RawStage ;
51
54
import com .google .firebase .firestore .testutil .IntegrationTestUtil ;
52
55
import java .util .Collections ;
@@ -367,13 +370,14 @@ public void whereWithOr() {
367
370
.collection (randomCol )
368
371
.where (or (eq ("genre" , "Romance" ), eq ("genre" , "Dystopian" )))
369
372
.select ("title" )
373
+ .sort (field ("title" ).ascending ())
370
374
.execute ();
371
375
assertThat (waitFor (execute ).getResults ())
372
376
.comparingElementsUsing (DATA_CORRESPONDENCE )
373
377
.containsExactly (
378
+ ImmutableMap .of ("title" , "1984" ),
374
379
ImmutableMap .of ("title" , "Pride and Prejudice" ),
375
- ImmutableMap .of ("title" , "The Handmaid's Tale" ),
376
- ImmutableMap .of ("title" , "1984" ));
380
+ ImmutableMap .of ("title" , "The Handmaid's Tale" ));
377
381
}
378
382
379
383
@ Test
@@ -418,6 +422,7 @@ public void arrayContainsAnyWorks() {
418
422
.collection (randomCol )
419
423
.where (arrayContainsAny ("tags" , ImmutableList .of ("comedy" , "classic" )))
420
424
.select ("title" )
425
+ .sort (field ("title" ).descending ())
421
426
.execute ();
422
427
assertThat (waitFor (execute ).getResults ())
423
428
.comparingElementsUsing (DATA_CORRESPONDENCE )
@@ -480,7 +485,8 @@ public void testStrConcat() {
480
485
firestore
481
486
.pipeline ()
482
487
.collection (randomCol )
483
- .select (field ("author" ).strConcat (" - " , field ("title" )).alias ("bookInfo" ))
488
+ .sort (ascending (Field .DOCUMENT_ID ))
489
+ .select (strConcat (field ("author" ), constant (" - " ), field ("title" )).alias ("bookInfo" ))
484
490
.limit (1 )
485
491
.execute ();
486
492
assertThat (waitFor (execute ).getResults ())
@@ -545,12 +551,12 @@ public void testLength() {
545
551
}
546
552
547
553
@ Test
548
- @ Ignore ("Not supported yet" )
549
554
public void testToLowercase () {
550
555
Task <PipelineSnapshot > execute =
551
556
firestore
552
557
.pipeline ()
553
558
.collection (randomCol )
559
+ .sort (Field .DOCUMENT_ID .ascending ())
554
560
.select (field ("title" ).toLower ().alias ("lowercaseTitle" ))
555
561
.limit (1 )
556
562
.execute ();
@@ -560,12 +566,12 @@ public void testToLowercase() {
560
566
}
561
567
562
568
@ Test
563
- @ Ignore ("Not supported yet" )
564
569
public void testToUppercase () {
565
570
Task <PipelineSnapshot > execute =
566
571
firestore
567
572
.pipeline ()
568
573
.collection (randomCol )
574
+ .sort (Field .DOCUMENT_ID .ascending ())
569
575
.select (field ("author" ).toUpper ().alias ("uppercaseAuthor" ))
570
576
.limit (1 )
571
577
.execute ();
@@ -597,6 +603,10 @@ public void testTrim() {
597
603
598
604
@ Test
599
605
public void testLike () {
606
+ if (isRunningAgainstEmulator ()) {
607
+ return ;
608
+ }
609
+
600
610
Task <PipelineSnapshot > execute =
601
611
firestore
602
612
.pipeline ()
@@ -611,6 +621,10 @@ public void testLike() {
611
621
612
622
@ Test
613
623
public void testRegexContains () {
624
+ if (isRunningAgainstEmulator ()) {
625
+ return ;
626
+ }
627
+
614
628
Task <PipelineSnapshot > execute =
615
629
firestore
616
630
.pipeline ()
@@ -622,6 +636,10 @@ public void testRegexContains() {
622
636
623
637
@ Test
624
638
public void testRegexMatches () {
639
+ if (isRunningAgainstEmulator ()) {
640
+ return ;
641
+ }
642
+
625
643
Task <PipelineSnapshot > execute =
626
644
firestore
627
645
.pipeline ()
@@ -637,12 +655,13 @@ public void testArithmeticOperations() {
637
655
firestore
638
656
.pipeline ()
639
657
.collection (randomCol )
658
+ .sort (ascending (Field .DOCUMENT_ID ))
659
+ .limit (1 )
640
660
.select (
641
661
add (field ("rating" ), 1 ).alias ("ratingPlusOne" ),
642
662
subtract (field ("published" ), 1900 ).alias ("yearsSince1900" ),
643
663
field ("rating" ).multiply (10 ).alias ("ratingTimesTen" ),
644
664
field ("rating" ).divide (2 ).alias ("ratingDividedByTwo" ))
645
- .limit (1 )
646
665
.execute ();
647
666
assertThat (waitFor (execute ).getResults ())
648
667
.comparingElementsUsing (DATA_CORRESPONDENCE )
@@ -749,6 +768,7 @@ public void testMapGet() {
749
768
firestore
750
769
.pipeline ()
751
770
.collection (randomCol )
771
+ .sort (field ("title" ).descending ())
752
772
.select (field ("awards" ).mapGet ("hugo" ).alias ("hugoAward" ), field ("title" ))
753
773
.where (eq ("hugoAward" , true ))
754
774
.execute ();
@@ -790,6 +810,7 @@ public void testNestedFields() {
790
810
.collection (randomCol )
791
811
.where (eq ("awards.hugo" , true ))
792
812
.select ("title" , "awards.hugo" )
813
+ .sort (field ("title" ).descending ())
793
814
.execute ();
794
815
assertThat (waitFor (execute ).getResults ())
795
816
.comparingElementsUsing (DATA_CORRESPONDENCE )
@@ -805,6 +826,7 @@ public void testMapGetWithFieldNameIncludingNotation() {
805
826
.pipeline ()
806
827
.collection (randomCol )
807
828
.where (eq ("awards.hugo" , true ))
829
+ .sort (field ("title" ).descending ())
808
830
.select (
809
831
"title" ,
810
832
field ("nestedField.level.1" ),
0 commit comments