16
16
17
17
package org .springframework .data .couchbase .repository ;
18
18
19
+ import static com .couchbase .client .java .query .QueryScanConsistency .REQUEST_PLUS ;
19
20
import static java .util .Arrays .asList ;
20
21
import static org .junit .jupiter .api .Assertions .assertEquals ;
21
22
import static org .junit .jupiter .api .Assertions .assertFalse ;
22
23
import static org .junit .jupiter .api .Assertions .assertThrows ;
23
24
import static org .junit .jupiter .api .Assertions .assertTrue ;
24
-
25
+ import static org .springframework .data .couchbase .config .BeanNames .COUCHBASE_TEMPLATE ;
26
+ import static org .springframework .data .couchbase .config .BeanNames .REACTIVE_COUCHBASE_TEMPLATE ;
27
+
28
+ import com .couchbase .client .java .query .QueryScanConsistency ;
29
+ import org .springframework .context .ApplicationContext ;
30
+ import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
31
+ import org .springframework .context .annotation .Bean ;
32
+ import org .springframework .data .auditing .DateTimeProvider ;
33
+ import org .springframework .data .couchbase .core .CouchbaseTemplate ;
34
+ import org .springframework .data .couchbase .core .ReactiveCouchbaseTemplate ;
35
+ import org .springframework .data .couchbase .domain .*;
36
+ import org .springframework .data .couchbase .domain .time .AuditingDateTimeProvider ;
37
+ import org .springframework .data .couchbase .repository .auditing .EnableCouchbaseAuditing ;
38
+ import org .springframework .data .couchbase .repository .config .EnableCouchbaseRepositories ;
25
39
import reactor .core .publisher .Flux ;
26
40
import reactor .core .publisher .Mono ;
27
41
import reactor .test .StepVerifier ;
28
42
29
43
import java .time .Instant ;
30
- import java .util .HashSet ;
31
- import java .util .List ;
32
- import java .util .Set ;
33
- import java .util .UUID ;
44
+ import java .util .*;
34
45
import java .util .concurrent .Callable ;
35
46
import java .util .concurrent .ExecutorService ;
36
47
import java .util .concurrent .Executors ;
44
55
import org .springframework .dao .DataRetrievalFailureException ;
45
56
import org .springframework .data .couchbase .CouchbaseClientFactory ;
46
57
import org .springframework .data .couchbase .config .AbstractCouchbaseConfiguration ;
47
- import org .springframework .data .couchbase .domain .Airport ;
48
- import org .springframework .data .couchbase .domain .ReactiveAirportRepository ;
49
- import org .springframework .data .couchbase .domain .ReactiveUserRepository ;
50
- import org .springframework .data .couchbase .domain .User ;
51
58
import org .springframework .data .couchbase .repository .config .EnableReactiveCouchbaseRepositories ;
52
59
import org .springframework .data .couchbase .util .Capabilities ;
53
60
import org .springframework .data .couchbase .util .ClusterType ;
@@ -249,6 +256,34 @@ void deleteAll() {
249
256
}
250
257
}
251
258
259
+ @ Test
260
+ public void saveNotBoundedRequestPlusWithDefaultRepository () {
261
+ ApplicationContext ac = new AnnotationConfigApplicationContext (ConfigRequestPlus .class );
262
+ // the Config class has been modified, these need to be loaded again
263
+ ReactiveCouchbaseTemplate couchbaseTemplateRP = (ReactiveCouchbaseTemplate ) ac .getBean (REACTIVE_COUCHBASE_TEMPLATE );
264
+ ReactiveAirportDefaultConsistencyRepository airportRepositoryRP = (ReactiveAirportDefaultConsistencyRepository ) ac .getBean ("reactiveAirportDefaultConsistencyRepository" );
265
+
266
+ List <Airport > sizeBeforeTest = airportRepositoryRP .findAll ().collectList ().block ();
267
+ assertEquals (0 , sizeBeforeTest .size ());
268
+
269
+ List <String > idsToRemove = new ArrayList <>(100 );
270
+ for (int i = 1 ; i <= 100 ; i ++) {
271
+ Airport vie = new Airport ("airports::vie" + i , "vie" + i , "low9" );
272
+ Airport saved = airportRepositoryRP .save (vie ).block ();
273
+ idsToRemove .add (saved .getId ());
274
+ }
275
+
276
+ List <Airport > allSaved = airportRepositoryRP .findAll ().collectList ().block ();
277
+
278
+ boolean success = allSaved .size () == 100 ;
279
+
280
+ for (String idToRemove : idsToRemove ) {
281
+ couchbaseTemplateRP .removeById ().one (idToRemove );
282
+ }
283
+
284
+ assertTrue (success );
285
+ }
286
+
252
287
@ Configuration
253
288
@ EnableReactiveCouchbaseRepositories ("org.springframework.data.couchbase" )
254
289
static class Config extends AbstractCouchbaseConfiguration {
@@ -275,4 +310,33 @@ public String getBucketName() {
275
310
276
311
}
277
312
313
+ @ Configuration
314
+ @ EnableReactiveCouchbaseRepositories ("org.springframework.data.couchbase" )
315
+ static class ConfigRequestPlus extends AbstractCouchbaseConfiguration {
316
+
317
+ @ Override
318
+ public String getConnectionString () {
319
+ return connectionString ();
320
+ }
321
+
322
+ @ Override
323
+ public String getUserName () {
324
+ return config ().adminUsername ();
325
+ }
326
+
327
+ @ Override
328
+ public String getPassword () {
329
+ return config ().adminPassword ();
330
+ }
331
+
332
+ @ Override
333
+ public String getBucketName () {
334
+ return bucketName ();
335
+ }
336
+
337
+ @ Override
338
+ public QueryScanConsistency getDefaultConsistency () {
339
+ return REQUEST_PLUS ;
340
+ }
341
+ }
278
342
}
0 commit comments