4242import java .util .List ;
4343import java .util .Map ;
4444import java .util .concurrent .CompletionStage ;
45+ import org .junit .jupiter .api .BeforeEach ;
4546import org .junit .jupiter .api .Test ;
4647import org .junit .jupiter .api .extension .RegisterExtension ;
4748import org .neo4j .driver .Bookmark ;
@@ -73,18 +74,26 @@ class SessionBoltV3IT {
7374 @ RegisterExtension
7475 static final DriverExtension driver = new DriverExtension ();
7576
77+ private static String showTxMetadata ;
78+
79+ @ BeforeEach
80+ void beforeAll () {
81+ showTxMetadata = driver .isNeo4j43OrEarlier ()
82+ ? "CALL dbms.listTransactions() YIELD metaData"
83+ : "SHOW TRANSACTIONS YIELD metaData" ;
84+ }
85+
7686 @ Test
7787 void shouldSetTransactionMetadata () {
7888 Map <String , Object > metadata = new HashMap <>();
7989 metadata .put ("a" , "hello world" );
8090 metadata .put ("b" , LocalDate .now ());
81- metadata .put ("c" , asList (true , false , true ));
91+ metadata .put ("c" , driver . isNeo4j43OrEarlier () ? asList (true , false , true ) : false );
8292
8393 TransactionConfig config =
8494 TransactionConfig .builder ().withMetadata (metadata ).build ();
8595
86- // call listTransactions procedure that should list itself with the specified metadata
87- Result result = driver .session ().run ("CALL dbms.listTransactions()" , config );
96+ Result result = driver .session ().run (showTxMetadata , config );
8897 Map <String , Object > receivedMetadata = result .single ().get ("metaData" ).asMap ();
8998
9099 assertEquals (metadata , receivedMetadata );
@@ -99,9 +108,8 @@ void shouldSetTransactionMetadataAsync() {
99108 TransactionConfig config =
100109 TransactionConfig .builder ().withMetadata (metadata ).build ();
101110
102- // call listTransactions procedure that should list itself with the specified metadata
103111 CompletionStage <Map <String , Object >> metadataFuture = driver .asyncSession ()
104- .runAsync ("CALL dbms.listTransactions()" , config )
112+ .runAsync (showTxMetadata , config )
105113 .thenCompose (ResultCursor ::singleAsync )
106114 .thenApply (record -> record .get ("metaData" ).asMap ());
107115
@@ -309,14 +317,11 @@ private static void testTransactionMetadataWithAsyncTransactionFunctions(boolean
309317 TransactionConfig config =
310318 TransactionConfig .builder ().withMetadata (metadata ).build ();
311319
312- // call listTransactions procedure that should list itself with the specified metadata
313320 CompletionStage <Record > singleFuture = read
314321 ? asyncSession .readTransactionAsync (
315- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
316- config )
322+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config )
317323 : asyncSession .writeTransactionAsync (
318- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
319- config );
324+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config );
320325
321326 CompletionStage <Map <String , Object >> metadataFuture =
322327 singleFuture .thenApply (record -> record .get ("metaData" ).asMap ());
@@ -334,12 +339,9 @@ private static void testTransactionMetadataWithTransactionFunctions(boolean read
334339 TransactionConfig config =
335340 TransactionConfig .builder ().withMetadata (metadata ).build ();
336341
337- // call listTransactions procedure that should list itself with the specified metadata
338342 Record single = read
339- ? session .readTransaction (
340- tx -> tx .run ("CALL dbms.listTransactions()" ).single (), config )
341- : session .writeTransaction (
342- tx -> tx .run ("CALL dbms.listTransactions()" ).single (), config );
343+ ? session .readTransaction (tx -> tx .run (showTxMetadata ).single (), config )
344+ : session .writeTransaction (tx -> tx .run (showTxMetadata ).single (), config );
343345
344346 Map <String , Object > receivedMetadata = single .get ("metaData" ).asMap ();
345347
0 commit comments