@@ -72,6 +72,7 @@ class DefaultDatabaseClientUnitTests {
72
72
73
73
private DatabaseClient .Builder databaseClientBuilder ;
74
74
75
+
75
76
@ BeforeEach
76
77
@ SuppressWarnings ({ "rawtypes" , "unchecked" })
77
78
void before () {
@@ -84,6 +85,7 @@ void before() {
84
85
connectionFactory ).bindMarkers (BindMarkersFactory .indexed ("$" , 1 ));
85
86
}
86
87
88
+
87
89
@ Test
88
90
void connectionFactoryIsExposed () {
89
91
ConnectionFactory connectionFactory = mock (ConnectionFactory .class );
@@ -96,7 +98,6 @@ void connectionFactoryIsExposed() {
96
98
@ Test
97
99
void shouldCloseConnectionOnlyOnce () {
98
100
DefaultDatabaseClient databaseClient = (DefaultDatabaseClient ) databaseClientBuilder .build ();
99
-
100
101
Flux <Object > flux = databaseClient .inConnectionMany (connection -> Flux .empty ());
101
102
102
103
flux .subscribe (new CoreSubscriber <Object >() {
@@ -147,7 +148,6 @@ void executeShouldBindNullValues() {
147
148
@ SuppressWarnings ("deprecation" )
148
149
void executeShouldBindSettableValues () {
149
150
Statement statement = mockStatementFor ("SELECT * FROM table WHERE key = $1" );
150
-
151
151
DatabaseClient databaseClient = databaseClientBuilder .namedParameters (false ).build ();
152
152
153
153
databaseClient .sql ("SELECT * FROM table WHERE key = $1" ).bind (0 ,
@@ -165,7 +165,6 @@ void executeShouldBindSettableValues() {
165
165
166
166
@ Test
167
167
void executeShouldBindNamedNullValues () {
168
-
169
168
Statement statement = mockStatementFor ("SELECT * FROM table WHERE key = $1" );
170
169
DatabaseClient databaseClient = databaseClientBuilder .build ();
171
170
@@ -198,7 +197,6 @@ void executeShouldBindNamedValuesFromIndexes() {
198
197
@ SuppressWarnings ("deprecation" )
199
198
void executeShouldBindValues () {
200
199
Statement statement = mockStatementFor ("SELECT * FROM table WHERE key = $1" );
201
-
202
200
DatabaseClient databaseClient = databaseClientBuilder .build ();
203
201
204
202
databaseClient .sql ("SELECT * FROM table WHERE key = $1" ).bind (0 ,
@@ -214,7 +212,6 @@ void executeShouldBindValues() {
214
212
215
213
@ Test
216
214
void executeShouldBindNamedValuesByIndex () {
217
-
218
215
Statement statement = mockStatementFor ("SELECT * FROM table WHERE key = $1" );
219
216
DatabaseClient databaseClient = databaseClientBuilder .build ();
220
217
@@ -227,9 +224,8 @@ void executeShouldBindNamedValuesByIndex() {
227
224
@ Test
228
225
@ SuppressWarnings ("unchecked" )
229
226
void rowsUpdatedShouldEmitSingleValue () {
230
-
231
227
Result result = mock (Result .class );
232
- when (result .getRowsUpdated ()).thenReturn (Mono .empty (), Mono .just (2 ), Flux .just (1 , 2 , 3 ));
228
+ when (result .getRowsUpdated ()).thenReturn (Mono .empty (), Mono .just (2L ), Flux .just (1L , 2L , 3L ));
233
229
mockStatementFor ("DROP TABLE tab;" , result );
234
230
235
231
DatabaseClient databaseClient = databaseClientBuilder .build ();
@@ -355,9 +351,7 @@ public void bindTo(BindTarget target) {
355
351
@ Test
356
352
void shouldApplyStatementFilterFunctions () {
357
353
MockResult result = MockResult .builder ().build ();
358
-
359
354
Statement statement = mockStatement (result );
360
-
361
355
DatabaseClient databaseClient = databaseClientBuilder .build ();
362
356
363
357
databaseClient .sql ("SELECT" ).filter (
@@ -376,9 +370,7 @@ void shouldApplyStatementFilterFunctions() {
376
370
@ Test
377
371
void shouldApplySimpleStatementFilterFunctions () {
378
372
MockResult result = mockSingleColumnEmptyResult ();
379
-
380
373
Statement statement = mockStatement (result );
381
-
382
374
DatabaseClient databaseClient = databaseClientBuilder .build ();
383
375
384
376
databaseClient .sql ("SELECT" ).filter (
@@ -393,6 +385,7 @@ void shouldApplySimpleStatementFilterFunctions() {
393
385
inOrder .verifyNoMoreInteractions ();
394
386
}
395
387
388
+
396
389
private Statement mockStatement () {
397
390
return mockStatementFor (null , null );
398
391
}
@@ -407,14 +400,10 @@ private Statement mockStatementFor(String sql) {
407
400
408
401
private Statement mockStatementFor (@ Nullable String sql , @ Nullable Result result ) {
409
402
Statement statement = mock (Statement .class );
410
- when (connection .createStatement (sql == null ? anyString () : eq (sql ))).thenReturn (
411
- statement );
403
+ when (connection .createStatement (sql == null ? anyString () : eq (sql ))).thenReturn (statement );
412
404
when (statement .returnGeneratedValues (anyString ())).thenReturn (statement );
413
405
when (statement .returnGeneratedValues ()).thenReturn (statement );
414
-
415
- doReturn (result == null ? Mono .empty () : Flux .just (result )).when (
416
- statement ).execute ();
417
-
406
+ doReturn (result == null ? Mono .empty () : Flux .just (result )).when (statement ).execute ();
418
407
return statement ;
419
408
}
420
409
0 commit comments