1- package redis .clients .jedis .search . aggr ;
1+ package redis .clients .jedis .modules . search ;
22
33import static org .junit .jupiter .api .Assertions .assertEquals ;
44import static org .junit .jupiter .api .Assertions .assertFalse ;
2828import redis .clients .jedis .search .Document ;
2929import redis .clients .jedis .search .IndexOptions ;
3030import redis .clients .jedis .search .Schema ;
31-
31+ import redis . clients . jedis . search . aggr .*;
3232
3333@ ParameterizedClass
3434@ MethodSource ("redis.clients.jedis.commands.CommandsTestsParameters#respVersions" )
@@ -190,7 +190,8 @@ public void testAggregateIteratorFirstBatchReturnsInitialResults() {
190190 assertEquals (10 , rows .get (1 ).getLong ("sum" ));
191191
192192 // 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 ());
194195 }
195196 }
196197
@@ -210,7 +211,7 @@ public void testAggregateIteratorEmptyResult() {
210211 // Test the iterator with empty results using the integrated method
211212 try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
212213 // Should have no results
213- assertFalse (iterator .hasNext ());
214+ assertTrue (iterator .next (). isEmpty ());
214215 }
215216 }
216217
@@ -269,11 +270,12 @@ public void testAggregateIteratorRemoveBeforeNext() {
269270 client .ftCreate (index , IndexOptions .defaultOptions (), sc );
270271
271272 addDocument (new Document ("data1" ).set ("name" , "abc" ).set ("count" , 10 ));
273+ addDocument (new Document ("data2" ).set ("name" , "cde" ).set ("count" , 8 ));
272274
273275 // Create aggregation with cursor
274276 AggregationBuilder aggr = new AggregationBuilder ()
275277 .groupBy ("@name" , Reducers .sum ("@count" ).as ("sum" ))
276- .cursor (10 , 10000 );
278+ .cursor (1 , 10000 );
277279
278280 // Test calling remove() before next() - should work since cursor is initialized
279281 try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
@@ -324,11 +326,12 @@ public void testAggregateIteratorRemoveMultipleTimes() {
324326 client .ftCreate (index , IndexOptions .defaultOptions (), sc );
325327
326328 addDocument (new Document ("data1" ).set ("name" , "abc" ).set ("count" , 10 ));
329+ addDocument (new Document ("data2" ).set ("name" , "cde" ).set ("count" , 3 ));
327330
328331 // Create aggregation with cursor
329332 AggregationBuilder aggr = new AggregationBuilder ()
330333 .groupBy ("@name" , Reducers .sum ("@count" ).as ("sum" ))
331- .cursor (10 , 10000 );
334+ .cursor (1 , 10000 );
332335
333336 // Test calling remove() multiple times
334337 try (AggregateIterator iterator = client .ftAggregateIterator (index , aggr )) {
@@ -337,11 +340,11 @@ public void testAggregateIteratorRemoveMultipleTimes() {
337340 // First remove should work
338341 iterator .remove ();
339342 assertFalse (iterator .hasNext ());
340- assertEquals (Long . valueOf (- 1 ) , iterator .getCursorId ());
343+ assertEquals (- 1L , iterator .getCursorId ());
341344
342345 // Second remove should not throw exception, just return silently
343346 iterator .remove (); // Should not throw
344- assertEquals (Long . valueOf (- 1 ) , iterator .getCursorId ());
347+ assertEquals (- 1L , iterator .getCursorId ());
345348 }
346349 }
347350}
0 commit comments