Skip to content

Commit 49001b8

Browse files
committed
Pretty
1 parent 79f0444 commit 49001b8

File tree

1 file changed

+115
-35
lines changed

1 file changed

+115
-35
lines changed

firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DisjunctiveTests.kt

Lines changed: 115 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ internal class DisjunctiveTests {
6363
.collection("/users")
6464
.where(
6565
field("name")
66-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric")))
66+
.eqAny(
67+
array(
68+
constant("alice"),
69+
constant("bob"),
70+
constant("charlie"),
71+
constant("diane"),
72+
constant("eric")
73+
)
74+
)
6775
)
6876

6977
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
@@ -85,7 +93,15 @@ internal class DisjunctiveTests {
8593
.where(
8694
and(
8795
field("name")
88-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric"))),
96+
.eqAny(
97+
array(
98+
constant("alice"),
99+
constant("bob"),
100+
constant("charlie"),
101+
constant("diane"),
102+
constant("eric")
103+
)
104+
),
89105
field("age").eqAny(array(constant(10.0), constant(25.0)))
90106
)
91107
)
@@ -108,7 +124,15 @@ internal class DisjunctiveTests {
108124
.collection("/users")
109125
.where(
110126
field("name")
111-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric")))
127+
.eqAny(
128+
array(
129+
constant("alice"),
130+
constant("bob"),
131+
constant("charlie"),
132+
constant("diane"),
133+
constant("eric")
134+
)
135+
)
112136
)
113137
.where(field("age").eqAny(array(constant(10.0), constant(25.0))))
114138

@@ -151,7 +175,10 @@ internal class DisjunctiveTests {
151175
val pipeline =
152176
RealtimePipelineSource(db)
153177
.collectionGroup("users")
154-
.where(field("name").eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))))
178+
.where(
179+
field("name")
180+
.eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric")))
181+
)
155182

156183
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
157184
assertThat(result).containsExactlyElementsIn(listOf(doc1, doc4))
@@ -169,7 +196,10 @@ internal class DisjunctiveTests {
169196
val pipeline =
170197
RealtimePipelineSource(db)
171198
.collection("/users")
172-
.where(field("name").eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))))
199+
.where(
200+
field("name")
201+
.eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric")))
202+
)
173203
.sort(field("age").ascending())
174204

175205
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
@@ -188,7 +218,10 @@ internal class DisjunctiveTests {
188218
val pipeline =
189219
RealtimePipelineSource(db)
190220
.collection("/users")
191-
.where(field("name").eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))))
221+
.where(
222+
field("name")
223+
.eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric")))
224+
)
192225
.sort(field("name").ascending())
193226

194227
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
@@ -210,7 +243,15 @@ internal class DisjunctiveTests {
210243
.where(
211244
and(
212245
field("name")
213-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric"))),
246+
.eqAny(
247+
array(
248+
constant("alice"),
249+
constant("bob"),
250+
constant("charlie"),
251+
constant("diane"),
252+
constant("eric")
253+
)
254+
),
214255
field("age").eq(constant(10.0))
215256
)
216257
)
@@ -278,7 +319,10 @@ internal class DisjunctiveTests {
278319
.collection("/users")
279320
.where(
280321
and(
281-
field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))),
322+
field("name")
323+
.eqAny(
324+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
325+
),
282326
field("age").gt(constant(10.0)),
283327
field("age").lt(constant(100.0))
284328
)
@@ -302,7 +346,10 @@ internal class DisjunctiveTests {
302346
.collection("/users")
303347
.where(
304348
and(
305-
field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))),
349+
field("name")
350+
.eqAny(
351+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
352+
),
306353
field("age").gte(constant(10.0)),
307354
field("age").lte(constant(100.0))
308355
)
@@ -326,7 +373,10 @@ internal class DisjunctiveTests {
326373
.collection("/users")
327374
.where(
328375
and(
329-
field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))),
376+
field("name")
377+
.eqAny(
378+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
379+
),
330380
field("age").gt(constant(10.0)),
331381
field("age").lt(constant(100.0))
332382
)
@@ -351,7 +401,10 @@ internal class DisjunctiveTests {
351401
.collection("/users")
352402
.where(
353403
and(
354-
field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))),
404+
field("name")
405+
.eqAny(
406+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
407+
),
355408
field("age").neq(constant(100.0))
356409
)
357410
)
@@ -372,7 +425,12 @@ internal class DisjunctiveTests {
372425
val pipeline =
373426
RealtimePipelineSource(db)
374427
.collection("/users")
375-
.where(field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))))
428+
.where(
429+
field("name")
430+
.eqAny(
431+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
432+
)
433+
)
376434
.sort(field("name").ascending())
377435

378436
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
@@ -412,7 +470,15 @@ internal class DisjunctiveTests {
412470
.where(
413471
and(
414472
field("name")
415-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric"))),
473+
.eqAny(
474+
array(
475+
constant("alice"),
476+
constant("bob"),
477+
constant("charlie"),
478+
constant("diane"),
479+
constant("eric")
480+
)
481+
),
416482
field("age").eq(constant(10.0))
417483
)
418484
)
@@ -437,7 +503,15 @@ internal class DisjunctiveTests {
437503
.where(
438504
and(
439505
field("name")
440-
.eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"), constant("eric"))),
506+
.eqAny(
507+
array(
508+
constant("alice"),
509+
constant("bob"),
510+
constant("charlie"),
511+
constant("diane"),
512+
constant("eric")
513+
)
514+
),
441515
field("age").eq(constant(10.0))
442516
)
443517
)
@@ -484,7 +558,10 @@ internal class DisjunctiveTests {
484558
.collection("/users")
485559
.where(
486560
and(
487-
field("name").eqAny(array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))),
561+
field("name")
562+
.eqAny(
563+
array(constant("alice"), constant("bob"), constant("charlie"), constant("diane"))
564+
),
488565
field("age").gt(constant(20.0))
489566
)
490567
)
@@ -584,11 +661,7 @@ internal class DisjunctiveTests {
584661
doc(
585662
"users/a",
586663
1000,
587-
mapOf(
588-
"name" to "alice",
589-
"groups" to listOf(1L, 2L, 3L),
590-
"records" to listOf("a", "b", "c")
591-
)
664+
mapOf("name" to "alice", "groups" to listOf(1L, 2L, 3L), "records" to listOf("a", "b", "c"))
592665
)
593666
val doc2 =
594667
doc(
@@ -610,11 +683,7 @@ internal class DisjunctiveTests {
610683
doc(
611684
"users/d",
612685
1000,
613-
mapOf(
614-
"name" to "diane",
615-
"groups" to listOf(2L, 3L, 5L),
616-
"records" to listOf("c", "d", "e")
617-
)
686+
mapOf("name" to "diane", "groups" to listOf(2L, 3L, 5L), "records" to listOf("c", "d", "e"))
618687
)
619688
val doc5 =
620689
doc(
@@ -643,7 +712,11 @@ internal class DisjunctiveTests {
643712
val doc1 = doc("users/a", 1000, mapOf("name" to "alice", "groups" to listOf(1L, 2L, 3L)))
644713
val doc2 = doc("users/b", 1000, mapOf("name" to "bob", "groups" to listOf(1L, 2L, 4L)))
645714
val doc3 =
646-
doc("users/c", 1000, mapOf("name" to "charlie", "groups" to listOf(2L, 3L, 4L))) // Filtered by LT
715+
doc(
716+
"users/c",
717+
1000,
718+
mapOf("name" to "charlie", "groups" to listOf(2L, 3L, 4L))
719+
) // Filtered by LT
647720
val doc4 = doc("users/d", 1000, mapOf("name" to "diane", "groups" to listOf(2L, 3L, 5L)))
648721
val doc5 = doc("users/e", 1000, mapOf("name" to "eric", "groups" to listOf(3L, 4L, 5L)))
649722
val documents = listOf(doc1, doc2, doc3, doc4, doc5)
@@ -905,7 +978,11 @@ internal class DisjunctiveTests {
905978
val doc1 = doc("users/a", 1000, mapOf("name" to "alice", "age" to 25.0, "height" to 170.0))
906979
val doc2 = doc("users/b", 1000, mapOf("name" to "bob", "age" to 25.0, "height" to 180.0))
907980
val doc3 =
908-
doc("users/c", 1000, mapOf("name" to "charlie", "age" to 100.0, "height" to 155.0)) // Not matched
981+
doc(
982+
"users/c",
983+
1000,
984+
mapOf("name" to "charlie", "age" to 100.0, "height" to 155.0)
985+
) // Not matched
909986
val doc4 = doc("users/d", 1000, mapOf("name" to "diane", "age" to 10.0, "height" to 150.0))
910987
val doc5 = doc("users/e", 1000, mapOf("name" to "eric", "age" to 25.0, "height" to 170.0))
911988
val documents = listOf(doc1, doc2, doc3, doc4, doc5)
@@ -914,11 +991,7 @@ internal class DisjunctiveTests {
914991
RealtimePipelineSource(db)
915992
.collection("/users")
916993
.where(or(field("age").lt(constant(80.0)), field("height").gt(constant(160.0))))
917-
.sort(
918-
field("age").ascending(),
919-
field("height").descending(),
920-
field("name").ascending()
921-
)
994+
.sort(field("age").ascending(), field("height").descending(), field("name").ascending())
922995

923996
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
924997
assertThat(result).containsExactly(doc4, doc2, doc1, doc5).inOrder()
@@ -1494,7 +1567,9 @@ internal class DisjunctiveTests {
14941567
val pipeline =
14951568
RealtimePipelineSource(db)
14961569
.collection("/users")
1497-
.where(field("score").eqAny(array(constant(50L), constant(97L), constant(97L), constant(97L))))
1570+
.where(
1571+
field("score").eqAny(array(constant(50L), constant(97L), constant(97L), constant(97L)))
1572+
)
14981573

14991574
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
15001575
assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3))
@@ -1526,7 +1601,10 @@ internal class DisjunctiveTests {
15261601
val pipeline =
15271602
RealtimePipelineSource(db)
15281603
.collection("/users")
1529-
.where(field("scores").arrayContainsAny(array(constant(1L), constant(2L), constant(2L), constant(2L))))
1604+
.where(
1605+
field("scores")
1606+
.arrayContainsAny(array(constant(1L), constant(2L), constant(2L), constant(2L)))
1607+
)
15301608

15311609
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
15321610
assertThat(result).containsExactly(doc1)
@@ -1543,7 +1621,9 @@ internal class DisjunctiveTests {
15431621
.collection("/users")
15441622
.where(
15451623
field("scores")
1546-
.arrayContainsAll(array(constant(1L), constant(2L), constant(2L), constant(2L), constant(3L)))
1624+
.arrayContainsAll(
1625+
array(constant(1L), constant(2L), constant(2L), constant(2L), constant(3L))
1626+
)
15471627
)
15481628
val result = runPipeline(db, pipeline, flowOf(*documents.toTypedArray())).toList()
15491629
// The C++ test `EXPECT_THAT(RunPipeline(pipeline, documents), ElementsAre(doc1, doc2));`

0 commit comments

Comments
 (0)