Skip to content

Commit 3c501c6

Browse files
committed
Add test case with no filters, no selections and no order by
1 parent 93a5e26 commit 3c501c6

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

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

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6219,6 +6219,62 @@ void testSearchCompleteQuery(String dataStoreName) throws JsonProcessingExceptio
62196219
}
62206220
assertEquals(5, count);
62216221
}
6222+
6223+
@ParameterizedTest
6224+
@ArgumentsSource(PostgresProvider.class)
6225+
void testSearchWithFilterSelectionsOrderByAndOffset(String dataStoreName)
6226+
throws JsonProcessingException {
6227+
Collection flatCollection = getFlatCollection(dataStoreName);
6228+
6229+
// Test covering: filter, selections, orderBy, and offset (pagination)
6230+
org.hypertrace.core.documentstore.Query legacyQuery =
6231+
new org.hypertrace.core.documentstore.Query()
6232+
.withFilter(
6233+
new org.hypertrace.core.documentstore.Filter(
6234+
org.hypertrace.core.documentstore.Filter.Op.GTE, "price", 5))
6235+
.withSelection("item")
6236+
.withSelection("price")
6237+
.withOrderBy(new OrderBy("price", true)) // ASC
6238+
.withLimit(3)
6239+
.withOffset(1); // Skip first result
6240+
6241+
Iterator<Document> results = flatCollection.search(legacyQuery);
6242+
int count = 0;
6243+
int previousPrice = Integer.MIN_VALUE;
6244+
while (results.hasNext()) {
6245+
Document doc = results.next();
6246+
JsonNode json = new ObjectMapper().readTree(doc.toJson());
6247+
assertTrue(json.has("item"));
6248+
assertTrue(json.has("price"));
6249+
int price = json.get("price").asInt();
6250+
assertTrue(price >= previousPrice); // ASC order
6251+
previousPrice = price;
6252+
count++;
6253+
}
6254+
assertEquals(3, count);
6255+
}
6256+
6257+
@ParameterizedTest
6258+
@ArgumentsSource(PostgresProvider.class)
6259+
void testSearchWithNullFilterEmptySelectionsNoOrderBy(String dataStoreName) {
6260+
Collection flatCollection = getFlatCollection(dataStoreName);
6261+
6262+
// Test covering null/empty branches:
6263+
// - No filter (null filter path)
6264+
// - No selections (empty selections path)
6265+
// - No orderBy (empty orderBys path)
6266+
// - Limit without offset (offset defaults to 0)
6267+
org.hypertrace.core.documentstore.Query legacyQuery =
6268+
new org.hypertrace.core.documentstore.Query().withLimit(5);
6269+
6270+
Iterator<Document> results = flatCollection.search(legacyQuery);
6271+
int count = 0;
6272+
while (results.hasNext()) {
6273+
results.next();
6274+
count++;
6275+
}
6276+
assertEquals(5, count);
6277+
}
62226278
}
62236279

62246280
@Nested

0 commit comments

Comments
 (0)