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,27 @@ 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
8696 // call listTransactions procedure that should list itself with the specified metadata
87- Result result = driver .session ().run ("CALL dbms.listTransactions()" , config );
97+ Result result = driver .session ().run (showTxMetadata , config );
8898 Map <String , Object > receivedMetadata = result .single ().get ("metaData" ).asMap ();
8999
90100 assertEquals (metadata , receivedMetadata );
@@ -101,7 +111,7 @@ void shouldSetTransactionMetadataAsync() {
101111
102112 // call listTransactions procedure that should list itself with the specified metadata
103113 CompletionStage <Map <String , Object >> metadataFuture = driver .asyncSession ()
104- .runAsync ("CALL dbms.listTransactions()" , config )
114+ .runAsync (showTxMetadata , config )
105115 .thenCompose (ResultCursor ::singleAsync )
106116 .thenApply (record -> record .get ("metaData" ).asMap ());
107117
@@ -312,11 +322,9 @@ private static void testTransactionMetadataWithAsyncTransactionFunctions(boolean
312322 // call listTransactions procedure that should list itself with the specified metadata
313323 CompletionStage <Record > singleFuture = read
314324 ? asyncSession .readTransactionAsync (
315- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
316- config )
325+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config )
317326 : asyncSession .writeTransactionAsync (
318- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
319- config );
327+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config );
320328
321329 CompletionStage <Map <String , Object >> metadataFuture =
322330 singleFuture .thenApply (record -> record .get ("metaData" ).asMap ());
@@ -336,10 +344,8 @@ private static void testTransactionMetadataWithTransactionFunctions(boolean read
336344
337345 // call listTransactions procedure that should list itself with the specified metadata
338346 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 );
347+ ? session .readTransaction (tx -> tx .run (showTxMetadata ).single (), config )
348+ : session .writeTransaction (tx -> tx .run (showTxMetadata ).single (), config );
343349
344350 Map <String , Object > receivedMetadata = single .get ("metaData" ).asMap ();
345351
0 commit comments