1
- package redis .clients .jedis .search . aggr ;
1
+ package redis .clients .jedis .modules . search ;
2
2
3
3
import static org .junit .jupiter .api .Assertions .assertEquals ;
4
4
import static org .junit .jupiter .api .Assertions .assertFalse ;
28
28
import redis .clients .jedis .search .Document ;
29
29
import redis .clients .jedis .search .IndexOptions ;
30
30
import redis .clients .jedis .search .Schema ;
31
-
31
+ import redis . clients . jedis . search . aggr .*;
32
32
33
33
@ ParameterizedClass
34
34
@ MethodSource ("redis.clients.jedis.commands.CommandsTestsParameters#respVersions" )
@@ -190,7 +190,8 @@ public void testAggregateIteratorFirstBatchReturnsInitialResults() {
190
190
assertEquals (10 , rows .get (1 ).getLong ("sum" ));
191
191
192
192
// Should be no more batches since we got all results in first batch
193
- assertFalse (iterator .hasNext ());
193
+ AggregationResult secondBatch = iterator .next ();
194
+ assertEquals (0 , secondBatch .getRows ().size ());
194
195
}
195
196
}
196
197
@@ -210,7 +211,7 @@ public void testAggregateIteratorEmptyResult() {
210
211
// Test the iterator with empty results using the integrated method
211
212
try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
212
213
// Should have no results
213
- assertFalse (iterator .hasNext ());
214
+ assertTrue (iterator .next (). isEmpty ());
214
215
}
215
216
}
216
217
@@ -269,11 +270,12 @@ public void testAggregateIteratorRemoveBeforeNext() {
269
270
client .ftCreate (index , IndexOptions .defaultOptions (), sc );
270
271
271
272
addDocument (new Document ("data1" ).set ("name" , "abc" ).set ("count" , 10 ));
273
+ addDocument (new Document ("data2" ).set ("name" , "cde" ).set ("count" , 8 ));
272
274
273
275
// Create aggregation with cursor
274
276
AggregationBuilder aggr = new AggregationBuilder ()
275
277
.groupBy ("@name" , Reducers .sum ("@count" ).as ("sum" ))
276
- .cursor (10 , 10000 );
278
+ .cursor (1 , 10000 );
277
279
278
280
// Test calling remove() before next() - should work since cursor is initialized
279
281
try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
@@ -324,11 +326,12 @@ public void testAggregateIteratorRemoveMultipleTimes() {
324
326
client .ftCreate (index , IndexOptions .defaultOptions (), sc );
325
327
326
328
addDocument (new Document ("data1" ).set ("name" , "abc" ).set ("count" , 10 ));
329
+ addDocument (new Document ("data2" ).set ("name" , "cde" ).set ("count" , 3 ));
327
330
328
331
// Create aggregation with cursor
329
332
AggregationBuilder aggr = new AggregationBuilder ()
330
333
.groupBy ("@name" , Reducers .sum ("@count" ).as ("sum" ))
331
- .cursor (10 , 10000 );
334
+ .cursor (1 , 10000 );
332
335
333
336
// Test calling remove() multiple times
334
337
try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
@@ -337,11 +340,11 @@ public void testAggregateIteratorRemoveMultipleTimes() {
337
340
// First remove should work
338
341
iterator .remove ();
339
342
assertFalse (iterator .hasNext ());
340
- assertEquals (Long . valueOf (- 1 ) , iterator .getCursorId ());
343
+ assertEquals (- 1L , iterator .getCursorId ());
341
344
342
345
// Second remove should not throw exception, just return silently
343
346
iterator .remove (); // Should not throw
344
- assertEquals (Long . valueOf (- 1 ) , iterator .getCursorId ());
347
+ assertEquals (- 1L , iterator .getCursorId ());
345
348
}
346
349
}
347
350
}
0 commit comments