Skip to content

Commit ce28574

Browse files
committed
Fixed failing test cases
1 parent cbb08fd commit ce28574

13 files changed

+156
-55
lines changed

document-store/src/integrationTest/java/org/hypertrace/core/documentstore/DocStoreQueryV1Test.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import com.typesafe.config.Config;
6969
import com.typesafe.config.ConfigFactory;
7070
import java.io.IOException;
71+
import java.util.ArrayList;
7172
import java.util.HashMap;
7273
import java.util.HashSet;
7374
import java.util.Iterator;
@@ -3219,7 +3220,7 @@ void testFlatPostgresCollectionFindAll(String dataStoreName) throws IOException
32193220
iterator.close();
32203221

32213222
// Should have 8 documents from the INSERT statements
3222-
assertEquals(10, count);
3223+
assertEquals(14, count);
32233224
}
32243225

32253226
@ParameterizedTest
@@ -3260,7 +3261,7 @@ void testFlatPostgresCollectionCount(String dataStoreName) {
32603261

32613262
// Test count method - all documents
32623263
long totalCount = flatCollection.count(Query.builder().build());
3263-
assertEquals(10, totalCount);
3264+
assertEquals(14, totalCount);
32643265

32653266
// Test count with filter - soap documents only
32663267
Query soapQuery =
@@ -3357,8 +3358,8 @@ void testFlatVsNestedCollectionConsistency(String dataStoreName) throws IOExcept
33573358
Query countAllQuery = Query.builder().build();
33583359
long nestedCount = nestedCollection.count(countAllQuery);
33593360
long flatCount = flatCollection.count(countAllQuery);
3360-
assertEquals(8, nestedCount, "Nested collection should have 8 documents");
3361-
assertEquals(10, flatCount, "Flat collection should have 10 documents");
3361+
assertEquals(14, nestedCount, "Nested collection should have 14 documents");
3362+
assertEquals(14, flatCount, "Flat collection should have 14 documents");
33623363

33633364
// Test 2: Filter by top-level field - item
33643365
Query itemFilterQuery =
@@ -3385,16 +3386,16 @@ void testFlatVsNestedCollectionConsistency(String dataStoreName) throws IOExcept
33853386

33863387
long nestedPriceCount = nestedCollection.count(priceFilterQuery);
33873388
long flatPriceCount = flatCollection.count(priceFilterQuery);
3388-
assertEquals(2, nestedPriceCount, "Nested should have 2 docs with price > 10");
3389-
assertEquals(3, flatPriceCount, "Flat should have 3 docs with price > 10");
3389+
assertEquals(4, nestedPriceCount, "Nested should have 4 docs with price > 10");
3390+
assertEquals(4, flatPriceCount, "Flat should have 4 docs with price > 10");
33903391

33913392
// Test 4: Compare actual document content for same filter
33923393
CloseableIterator<Document> nestedIterator = nestedCollection.find(itemFilterQuery);
33933394
CloseableIterator<Document> flatIterator = flatCollection.find(itemFilterQuery);
33943395

33953396
// Collect documents from both collections
3396-
java.util.List<String> nestedDocs = new java.util.ArrayList<>();
3397-
java.util.List<String> flatDocs = new java.util.ArrayList<>();
3397+
List<String> nestedDocs = new ArrayList<>();
3398+
List<String> flatDocs = new ArrayList<>();
33983399

33993400
while (nestedIterator.hasNext()) {
34003401
nestedDocs.add(nestedIterator.next().toJson());
@@ -3503,7 +3504,7 @@ void testFlatPostgresCollectionUnnestTags(String dataStoreName) throws IOExcepti
35033504

35043505
Iterator<Document> resultIterator = flatCollection.aggregate(unnestQuery);
35053506
assertDocsAndSizeEqualWithoutOrder(
3506-
dataStoreName, resultIterator, "query/flat_unnest_tags_response.json", 17);
3507+
dataStoreName, resultIterator, "query/flat_unnest_tags_response.json", 19);
35073508
}
35083509

35093510
/**
@@ -3771,7 +3772,7 @@ void testFlatPostgresCollectionUnnestMixedCaseField(String dataStoreName) throws
37713772
Iterator<Document> resultIterator = flatCollection.aggregate(unnestQuery);
37723773
// Expected categories: Hygiene(3), PersonalCare(2), HairCare(2), HomeDecor(1), Grooming(2)
37733774
assertDocsAndSizeEqualWithoutOrder(
3774-
dataStoreName, resultIterator, "query/flat_unnest_mixed_case_response.json", 5);
3775+
dataStoreName, resultIterator, "query/flat_unnest_mixed_case_response.json", 6);
37753776
}
37763777

37773778
@ParameterizedTest
@@ -3798,7 +3799,7 @@ void testFlatPostgresCollectionIntegerArrayFilter(String dataStoreName) throws I
37983799

37993800
Iterator<Document> resultIterator = flatCollection.find(integerArrayQuery);
38003801
assertDocsAndSizeEqualWithoutOrder(
3801-
dataStoreName, resultIterator, "query/flat_integer_array_filter_response.json", 1);
3802+
dataStoreName, resultIterator, "query/flat_integer_array_filter_response.json", 2);
38023803
}
38033804

38043805
@ParameterizedTest
@@ -3873,7 +3874,7 @@ void testFlatCollectionNestedJsonSelections(String dataStoreName) throws IOExcep
38733874

38743875
Iterator<Document> brandIterator = flatCollection.find(brandSelectionQuery);
38753876
assertDocsAndSizeEqualWithoutOrder(
3876-
dataStoreName, brandIterator, "query/flat_jsonb_brand_selection_response.json", 10);
3877+
dataStoreName, brandIterator, "query/flat_jsonb_brand_selection_response.json", 14);
38773878

38783879
// Test 2: Select deeply nested STRING field from JSONB column (props.seller.address.city)
38793880
Query citySelectionQuery =
@@ -3883,15 +3884,15 @@ void testFlatCollectionNestedJsonSelections(String dataStoreName) throws IOExcep
38833884

38843885
Iterator<Document> cityIterator = flatCollection.find(citySelectionQuery);
38853886
assertDocsAndSizeEqualWithoutOrder(
3886-
dataStoreName, cityIterator, "query/flat_jsonb_city_selection_response.json", 10);
3887+
dataStoreName, cityIterator, "query/flat_jsonb_city_selection_response.json", 14);
38873888

38883889
// Test 3: Select STRING_ARRAY field from JSONB column (props.colors)
38893890
Query colorsSelectionQuery =
38903891
Query.builder().addSelection(JsonIdentifierExpression.of("props", "colors")).build();
38913892

38923893
Iterator<Document> colorsIterator = flatCollection.find(colorsSelectionQuery);
38933894
assertDocsAndSizeEqualWithoutOrder(
3894-
dataStoreName, colorsIterator, "query/flat_jsonb_colors_selection_response.json", 10);
3895+
dataStoreName, colorsIterator, "query/flat_jsonb_colors_selection_response.json", 14);
38953896
}
38963897

38973898
@ParameterizedTest

document-store/src/integrationTest/resources/query/collection_data.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,47 @@
183183
"price": 10,
184184
"quantity": 5,
185185
"date": "2016-02-06T20:20:13Z"
186+
},
187+
{
188+
"_id": 9,
189+
"item": "Bottle",
190+
"price": 15,
191+
"quantity": 3,
192+
"date": "2016-03-01T10:00:00Z"
193+
},
194+
{
195+
"_id": 10,
196+
"item": "Cup",
197+
"price": 8,
198+
"quantity": 2,
199+
"date": "2016-04-01T10:00:00Z"
200+
},
201+
{
202+
"_id": 11,
203+
"item": "Pencil",
204+
"price": 2,
205+
"quantity": 50,
206+
"date": "2016-05-01T10:00:00Z"
207+
},
208+
{
209+
"_id": 12,
210+
"item": "Eraser",
211+
"price": 1,
212+
"quantity": 100,
213+
"date": "2016-06-01T10:00:00Z"
214+
},
215+
{
216+
"_id": 13,
217+
"item": "Notebook",
218+
"price": 25,
219+
"quantity": 10,
220+
"date": "2016-07-01T10:00:00Z"
221+
},
222+
{
223+
"_id": 14,
224+
"item": "Pen",
225+
"price": 5,
226+
"quantity": 20,
227+
"date": "2016-08-01T10:00:00Z"
186228
}
187229
]

document-store/src/integrationTest/resources/query/flat_integer_array_filter_response.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
{
33
"item": "Mirror",
44
"price": 20
5+
},
6+
{
7+
"item": "Pen",
8+
"price": 5
59
}
6-
]
10+
]

document-store/src/integrationTest/resources/query/flat_jsonb_brand_selection_response.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@
2020
{},
2121
{},
2222
{},
23+
{},
24+
{},
25+
{},
26+
{},
2327
{}
24-
]
28+
]

document-store/src/integrationTest/resources/query/flat_jsonb_city_selection_response.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
}
99
}
1010
},
11-
{
12-
},
11+
{},
1312
{
1413
"props": {
1514
"seller": {
@@ -19,8 +18,7 @@
1918
}
2019
}
2120
},
22-
{
23-
},
21+
{},
2422
{
2523
"props": {
2624
"seller": {
@@ -30,8 +28,7 @@
3028
}
3129
}
3230
},
33-
{
34-
},
31+
{},
3532
{
3633
"props": {
3734
"seller": {
@@ -43,5 +40,9 @@
4340
},
4441
{},
4542
{},
43+
{},
44+
{},
45+
{},
46+
{},
4647
{}
47-
]
48+
]

document-store/src/integrationTest/resources/query/flat_jsonb_colors_selection_response.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77
]
88
}
99
},
10+
{},
1011
{
1112
"props": {
1213
"colors": [
1314
"Black"
1415
]
1516
}
1617
},
18+
{},
1719
{
1820
"props": {
1921
"colors": [
@@ -22,6 +24,7 @@
2224
]
2325
}
2426
},
27+
{},
2528
{
2629
"props": {
2730
"colors": []
@@ -32,5 +35,6 @@
3235
{},
3336
{},
3437
{},
38+
{},
3539
{}
36-
]
40+
]

document-store/src/integrationTest/resources/query/flat_jsonb_group_by_brand_test_response.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"count": 7
3+
"count": 11
44
},
55
{
66
"props": {
Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
[
2-
{"categoryTags": "Hygiene", "count": 3},
3-
{"categoryTags": "PersonalCare", "count": 2},
4-
{"categoryTags": "HairCare", "count": 2},
5-
{"categoryTags": "HomeDecor", "count": 1},
6-
{"categoryTags": "Grooming", "count": 2}
7-
]
2+
{
3+
"categoryTags": "PersonalCare",
4+
"count": 2
5+
},
6+
{
7+
"categoryTags": "HomeDecor",
8+
"count": 1
9+
},
10+
{
11+
"categoryTags": "Hygiene",
12+
"count": 3
13+
},
14+
{
15+
"categoryTags": "Stationery",
16+
"count": 1
17+
},
18+
{
19+
"categoryTags": "HairCare",
20+
"count": 2
21+
},
22+
{
23+
"categoryTags": "Grooming",
24+
"count": 2
25+
}
26+
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
22
{
3-
"count": 25
3+
"count": 28
44
}
55
]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
22
{
3-
"count": 27
3+
"count": 32
44
}
55
]

0 commit comments

Comments
 (0)