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 ;
61
68
*
62
69
* @author Michael Nitschinger
63
70
* @author Michael Reiche
71
+ * @author Jonathan Massuchetti
64
72
*/
65
73
@ SpringJUnitConfig (ReactiveCouchbaseRepositoryQueryIntegrationTests .Config .class )
66
74
@ IgnoreWhen (missesCapabilities = Capabilities .QUERY , clusterTypes = ClusterType .MOCKED )
@@ -249,6 +257,34 @@ void deleteAll() {
249
257
}
250
258
}
251
259
260
+ @ Test
261
+ public void saveNotBoundedRequestPlusWithDefaultRepository () {
262
+ ApplicationContext ac = new AnnotationConfigApplicationContext (ConfigRequestPlus .class );
263
+ // the Config class has been modified, these need to be loaded again
264
+ ReactiveCouchbaseTemplate couchbaseTemplateRP = (ReactiveCouchbaseTemplate ) ac .getBean (REACTIVE_COUCHBASE_TEMPLATE );
265
+ ReactiveAirportDefaultConsistencyRepository airportRepositoryRP = (ReactiveAirportDefaultConsistencyRepository ) ac .getBean ("reactiveAirportDefaultConsistencyRepository" );
266
+
267
+ List <Airport > sizeBeforeTest = airportRepositoryRP .findAll ().collectList ().block ();
268
+ assertEquals (0 , sizeBeforeTest .size ());
269
+
270
+ List <String > idsToRemove = new ArrayList <>(100 );
271
+ for (int i = 1 ; i <= 100 ; i ++) {
272
+ Airport vie = new Airport ("airports::vie" + i , "vie" + i , "low9" );
273
+ Airport saved = airportRepositoryRP .save (vie ).block ();
274
+ idsToRemove .add (saved .getId ());
275
+ }
276
+
277
+ List <Airport > allSaved = airportRepositoryRP .findAll ().collectList ().block ();
278
+
279
+ boolean success = allSaved .size () == 100 ;
280
+
281
+ for (String idToRemove : idsToRemove ) {
282
+ couchbaseTemplateRP .removeById ().one (idToRemove );
283
+ }
284
+
285
+ assertTrue (success );
286
+ }
287
+
252
288
@ Configuration
253
289
@ EnableReactiveCouchbaseRepositories ("org.springframework.data.couchbase" )
254
290
static class Config extends AbstractCouchbaseConfiguration {
@@ -275,4 +311,33 @@ public String getBucketName() {
275
311
276
312
}
277
313
314
+ @ Configuration
315
+ @ EnableReactiveCouchbaseRepositories ("org.springframework.data.couchbase" )
316
+ static class ConfigRequestPlus extends AbstractCouchbaseConfiguration {
317
+
318
+ @ Override
319
+ public String getConnectionString () {
320
+ return connectionString ();
321
+ }
322
+
323
+ @ Override
324
+ public String getUserName () {
325
+ return config ().adminUsername ();
326
+ }
327
+
328
+ @ Override
329
+ public String getPassword () {
330
+ return config ().adminPassword ();
331
+ }
332
+
333
+ @ Override
334
+ public String getBucketName () {
335
+ return bucketName ();
336
+ }
337
+
338
+ @ Override
339
+ public QueryScanConsistency getDefaultConsistency () {
340
+ return REQUEST_PLUS ;
341
+ }
342
+ }
278
343
}
0 commit comments