30
30
import org .neo4j .driver .Record ;
31
31
import org .neo4j .driver .SessionConfig ;
32
32
import org .neo4j .driver .Values ;
33
- import org .neo4j .driver .reactive .ReactiveResult ;
34
- import org .neo4j .driver .reactive .ReactiveSession ;
33
+ import org .neo4j .driver .reactivestreams .ReactiveResult ;
34
+ import org .neo4j .driver .reactivestreams .ReactiveSession ;
35
35
import org .neo4j .driver .summary .ResultSummary ;
36
36
import org .neo4j .driver .types .TypeSystem ;
37
37
import org .springframework .data .neo4j .core .transaction .Neo4jTransactionUtils ;
38
38
import org .springframework .lang .Nullable ;
39
39
import org .springframework .util .ReflectionUtils ;
40
- import reactor .adapter .JdkFlowAdapter ;
41
40
import reactor .core .publisher .Flux ;
42
41
import reactor .core .publisher .Mono ;
43
42
import reactor .core .scheduler .Schedulers ;
@@ -89,10 +88,10 @@ void prepareMocks() {
89
88
90
89
when (driver .defaultTypeSystem ()).thenReturn (typeSystem );
91
90
92
- when (driver .reactiveSession ( any (SessionConfig .class ))).thenReturn (session );
91
+ when (driver .session ( eq ( ReactiveSession . class ), any (SessionConfig .class ))).thenReturn (session );
93
92
94
93
when (session .lastBookmarks ()).thenReturn (Set .of (Mockito .mock (Bookmark .class )));
95
- when (session .close ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .empty () ));
94
+ when (session .close ()).thenReturn (Mono .empty ());
96
95
}
97
96
98
97
@ AfterEach
@@ -107,9 +106,9 @@ void databaseSelectionShouldWorkBeforeAsUser() {
107
106
108
107
prepareMocks ();
109
108
110
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
111
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ).publishOn (Schedulers .single () )));
112
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
109
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
110
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ).publishOn (Schedulers .single ()));
111
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
113
112
114
113
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
115
114
@@ -146,9 +145,9 @@ void databaseSelectionShouldWorkAfterAsUser() {
146
145
147
146
prepareMocks ();
148
147
149
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
150
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ).publishOn (Schedulers .single () )));
151
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
148
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
149
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ).publishOn (Schedulers .single ()));
150
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
152
151
153
152
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
154
153
@@ -185,9 +184,9 @@ void userSelectionShouldWork() {
185
184
186
185
prepareMocks ();
187
186
188
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
189
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ).publishOn (Schedulers .single () )));
190
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
187
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
188
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ).publishOn (Schedulers .single ()));
189
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
191
190
192
191
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
193
192
@@ -222,9 +221,9 @@ void queryCreationShouldFeelGood() {
222
221
223
222
prepareMocks ();
224
223
225
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
226
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ) ));
227
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
224
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
225
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ));
226
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
228
227
229
228
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
230
229
@@ -266,9 +265,9 @@ void databaseSelectionShouldBePossibleOnlyOnce() {
266
265
267
266
prepareMocks ();
268
267
269
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
270
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ).publishOn (Schedulers .single () )));
271
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
268
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
269
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ).publishOn (Schedulers .single ()));
270
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
272
271
273
272
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
274
273
@@ -318,9 +317,9 @@ void databaseSelectionBeanShouldGetRespectedIfExisting() {
318
317
319
318
prepareMocks ();
320
319
321
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
322
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ).publishOn (Schedulers .single () )));
323
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
320
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
321
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ).publishOn (Schedulers .single ()));
322
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
324
323
325
324
String databaseName = "customDatabaseSelection" ;
326
325
String cypher = "RETURN 1" ;
@@ -407,9 +406,9 @@ void reading() {
407
406
408
407
prepareMocks ();
409
408
410
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
411
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 ) ));
412
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
409
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
410
+ when (result .records ()).thenReturn (Flux .just (record1 ));
411
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
413
412
when (record1 .get ("name" )).thenReturn (Values .value ("michael" ));
414
413
415
414
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
@@ -440,9 +439,9 @@ void shouldApplyNullChecksDuringReading() {
440
439
441
440
prepareMocks ();
442
441
443
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
444
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 , record2 ) ));
445
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
442
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
443
+ when (result .records ()).thenReturn (Flux .just (record1 , record2 ));
444
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
446
445
when (record1 .get ("name" )).thenReturn (Values .value ("michael" ));
447
446
448
447
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
@@ -473,8 +472,8 @@ void writing() {
473
472
474
473
prepareMocks ();
475
474
476
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
477
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
475
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
476
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
478
477
479
478
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
480
479
@@ -505,9 +504,9 @@ void automaticConversion() {
505
504
506
505
prepareMocks ();
507
506
508
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
509
- when (result .records ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Flux .just (record1 ) ));
510
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
507
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
508
+ when (result .records ()).thenReturn (Flux .just (record1 ));
509
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
511
510
when (record1 .size ()).thenReturn (1 );
512
511
when (record1 .get (0 )).thenReturn (Values .value (23L ));
513
512
@@ -534,8 +533,8 @@ void queriesWithoutResultShouldFitInAsWell() {
534
533
535
534
prepareMocks ();
536
535
537
- when (session .run (anyString (), anyMap ())).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (result ) ));
538
- when (result .consume ()).thenReturn (JdkFlowAdapter . publisherToFlowPublisher ( Mono .just (resultSummary ) ));
536
+ when (session .run (anyString (), anyMap ())).thenReturn (Mono .just (result ));
537
+ when (result .consume ()).thenReturn (Mono .just (resultSummary ));
539
538
540
539
ReactiveNeo4jClient client = ReactiveNeo4jClient .create (driver );
541
540
@@ -559,7 +558,7 @@ void queriesWithoutResultShouldFitInAsWell() {
559
558
560
559
void verifyDatabaseSelection (@ Nullable String targetDatabase ) {
561
560
562
- verify (driver ).reactiveSession ( configArgumentCaptor .capture ());
561
+ verify (driver ).session ( eq ( ReactiveSession . class ), configArgumentCaptor .capture ());
563
562
SessionConfig config = configArgumentCaptor .getValue ();
564
563
565
564
if (targetDatabase != null ) {
@@ -571,7 +570,7 @@ void verifyDatabaseSelection(@Nullable String targetDatabase) {
571
570
572
571
void verifyUserSelection (@ Nullable String aUser ) {
573
572
574
- verify (driver ).reactiveSession ( configArgumentCaptor .capture ());
573
+ verify (driver ).session ( eq ( ReactiveSession . class ), configArgumentCaptor .capture ());
575
574
SessionConfig config = configArgumentCaptor .getValue ();
576
575
577
576
// We assume the driver supports this before the test
0 commit comments