@@ -778,6 +778,26 @@ void queryCursor(ArangoDatabaseAsync db) throws ExecutionException, InterruptedE
778
778
assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
779
779
}
780
780
781
+ @ ParameterizedTest
782
+ @ MethodSource ("asyncDbs" )
783
+ void queryCursorInTx (ArangoDatabaseAsync db ) throws ExecutionException , InterruptedException {
784
+ StreamTransactionEntity tx = db .beginStreamTransaction (new StreamTransactionOptions ()).get ();
785
+ ArangoCursorAsync <Integer > c1 = db .query ("for i in 1..4 return i" , Integer .class ,
786
+ new AqlQueryOptions ().batchSize (1 ).streamTransactionId (tx .getId ())).get ();
787
+ List <Integer > result = new ArrayList <>();
788
+ result .addAll (c1 .getResult ());
789
+ ArangoCursorAsync <Integer > c2 = c1 .nextBatch ().get ();
790
+ result .addAll (c2 .getResult ());
791
+ ArangoCursorAsync <Integer > c3 = db .cursor (c2 .getId (), Integer .class ,
792
+ new AqlQueryOptions ().streamTransactionId (tx .getId ())).get ();
793
+ result .addAll (c3 .getResult ());
794
+ ArangoCursorAsync <Integer > c4 = c3 .nextBatch ().get ();
795
+ result .addAll (c4 .getResult ());
796
+ assertThat (c4 .hasMore ()).isFalse ();
797
+ assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
798
+ db .abortStreamTransaction (tx .getId ()).get ();
799
+ }
800
+
781
801
@ ParameterizedTest
782
802
@ MethodSource ("asyncDbs" )
783
803
void queryCursorRetry (ArangoDatabaseAsync db ) throws ExecutionException , InterruptedException {
@@ -797,6 +817,28 @@ void queryCursorRetry(ArangoDatabaseAsync db) throws ExecutionException, Interru
797
817
assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
798
818
}
799
819
820
+ @ ParameterizedTest
821
+ @ MethodSource ("asyncDbs" )
822
+ void queryCursorRetryInTx (ArangoDatabaseAsync db ) throws ExecutionException , InterruptedException {
823
+ assumeTrue (isAtLeastVersion (3 , 11 ));
824
+ StreamTransactionEntity tx = db .beginStreamTransaction (new StreamTransactionOptions ()).get ();
825
+ ArangoCursorAsync <Integer > c1 = db .query ("for i in 1..4 return i" , Integer .class ,
826
+ new AqlQueryOptions ().batchSize (1 ).allowRetry (true ).streamTransactionId (tx .getId ())).get ();
827
+ List <Integer > result = new ArrayList <>();
828
+ result .addAll (c1 .getResult ());
829
+ ArangoCursorAsync <Integer > c2 = c1 .nextBatch ().get ();
830
+ result .addAll (c2 .getResult ());
831
+ ArangoCursorAsync <Integer > c3 = db .cursor (c2 .getId (), Integer .class , c2 .getNextBatchId (),
832
+ new AqlQueryOptions ().streamTransactionId (tx .getId ())).get ();
833
+ result .addAll (c3 .getResult ());
834
+ ArangoCursorAsync <Integer > c4 = c3 .nextBatch ().get ();
835
+ result .addAll (c4 .getResult ());
836
+ c4 .close ();
837
+ assertThat (c4 .hasMore ()).isFalse ();
838
+ assertThat (result ).containsExactly (1 , 2 , 3 , 4 );
839
+ db .abortStreamTransaction (tx .getId ()).get ();
840
+ }
841
+
800
842
@ ParameterizedTest
801
843
@ MethodSource ("asyncDbs" )
802
844
void changeQueryTrackingProperties (ArangoDatabaseAsync db ) throws ExecutionException , InterruptedException {
0 commit comments