42
42
import java .util .List ;
43
43
import java .util .Map ;
44
44
import java .util .concurrent .CompletionStage ;
45
+ import org .junit .jupiter .api .BeforeEach ;
45
46
import org .junit .jupiter .api .Test ;
46
47
import org .junit .jupiter .api .extension .RegisterExtension ;
47
48
import org .neo4j .driver .Bookmark ;
@@ -73,18 +74,27 @@ class SessionBoltV3IT {
73
74
@ RegisterExtension
74
75
static final DriverExtension driver = new DriverExtension ();
75
76
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
+
76
86
@ Test
77
87
void shouldSetTransactionMetadata () {
78
88
Map <String , Object > metadata = new HashMap <>();
79
89
metadata .put ("a" , "hello world" );
80
90
metadata .put ("b" , LocalDate .now ());
81
- metadata .put ("c" , asList (true , false , true ));
91
+ metadata .put ("c" , driver . isNeo4j43OrEarlier () ? asList (true , false , true ) : false );
82
92
83
93
TransactionConfig config =
84
94
TransactionConfig .builder ().withMetadata (metadata ).build ();
85
95
86
96
// 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 );
88
98
Map <String , Object > receivedMetadata = result .single ().get ("metaData" ).asMap ();
89
99
90
100
assertEquals (metadata , receivedMetadata );
@@ -101,7 +111,7 @@ void shouldSetTransactionMetadataAsync() {
101
111
102
112
// call listTransactions procedure that should list itself with the specified metadata
103
113
CompletionStage <Map <String , Object >> metadataFuture = driver .asyncSession ()
104
- .runAsync ("CALL dbms.listTransactions()" , config )
114
+ .runAsync (showTxMetadata , config )
105
115
.thenCompose (ResultCursor ::singleAsync )
106
116
.thenApply (record -> record .get ("metaData" ).asMap ());
107
117
@@ -312,11 +322,9 @@ private static void testTransactionMetadataWithAsyncTransactionFunctions(boolean
312
322
// call listTransactions procedure that should list itself with the specified metadata
313
323
CompletionStage <Record > singleFuture = read
314
324
? asyncSession .readTransactionAsync (
315
- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
316
- config )
325
+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config )
317
326
: asyncSession .writeTransactionAsync (
318
- tx -> tx .runAsync ("CALL dbms.listTransactions()" ).thenCompose (ResultCursor ::singleAsync ),
319
- config );
327
+ tx -> tx .runAsync (showTxMetadata ).thenCompose (ResultCursor ::singleAsync ), config );
320
328
321
329
CompletionStage <Map <String , Object >> metadataFuture =
322
330
singleFuture .thenApply (record -> record .get ("metaData" ).asMap ());
@@ -336,10 +344,8 @@ private static void testTransactionMetadataWithTransactionFunctions(boolean read
336
344
337
345
// call listTransactions procedure that should list itself with the specified metadata
338
346
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 );
343
349
344
350
Map <String , Object > receivedMetadata = single .get ("metaData" ).asMap ();
345
351
0 commit comments