23
23
import static org .junit .jupiter .api .Assertions .assertThrows ;
24
24
import static org .junit .jupiter .api .Assertions .assertTrue ;
25
25
26
+ import java .lang .reflect .Method ;
26
27
import java .util .ArrayList ;
27
28
import java .util .Arrays ;
28
29
import java .util .List ;
41
42
import org .springframework .dao .DataIntegrityViolationException ;
42
43
import org .springframework .data .couchbase .CouchbaseClientFactory ;
43
44
import org .springframework .data .couchbase .config .AbstractCouchbaseConfiguration ;
45
+ import org .springframework .data .couchbase .core .CouchbaseTemplate ;
44
46
import org .springframework .data .couchbase .domain .Address ;
45
47
import org .springframework .data .couchbase .domain .Airport ;
46
48
import org .springframework .data .couchbase .domain .AirportRepository ;
49
51
import org .springframework .data .couchbase .domain .User ;
50
52
import org .springframework .data .couchbase .domain .UserRepository ;
51
53
import org .springframework .data .couchbase .repository .config .EnableCouchbaseRepositories ;
54
+ import org .springframework .data .couchbase .repository .query .CouchbaseQueryMethod ;
55
+ import org .springframework .data .couchbase .repository .query .CouchbaseRepositoryQuery ;
52
56
import org .springframework .data .couchbase .util .Capabilities ;
53
57
import org .springframework .data .couchbase .util .ClusterAwareIntegrationTests ;
54
58
import org .springframework .data .couchbase .util .ClusterType ;
55
59
import org .springframework .data .couchbase .util .IgnoreWhen ;
56
60
import org .springframework .data .domain .Page ;
57
61
import org .springframework .data .domain .PageRequest ;
58
62
import org .springframework .data .domain .Pageable ;
63
+ import org .springframework .data .projection .SpelAwareProxyProjectionFactory ;
64
+ import org .springframework .data .repository .core .support .DefaultRepositoryMetadata ;
59
65
import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
60
66
61
67
import com .couchbase .client .core .error .IndexExistsException ;
@@ -77,6 +83,8 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
77
83
78
84
@ Autowired UserRepository userRepository ;
79
85
86
+ @ Autowired CouchbaseTemplate couchbaseTemplate ;
87
+
80
88
@ BeforeEach
81
89
public void beforeEach () {
82
90
try {
@@ -287,6 +295,39 @@ void threadSafeStringParametersTest() throws Exception {
287
295
}
288
296
}
289
297
298
+ @ Test // DATACOUCH-650
299
+ void deleteAllById () {
300
+
301
+ Airport vienna = new Airport ("airports::vie" , "vie" , "LOWW" );
302
+ Airport frankfurt = new Airport ("airports::fra" , "fra" , "EDDF" );
303
+ Airport losAngeles = new Airport ("airports::lax" , "lax" , "KLAX" );
304
+
305
+ try {
306
+ airportRepository .saveAll (asList (vienna , frankfurt , losAngeles ));
307
+
308
+ airportRepository .deleteAllById (asList (vienna .getId (), losAngeles .getId ()));
309
+
310
+ assertThat (airportRepository .findAll ()).containsExactly (frankfurt );
311
+ } finally {
312
+ airportRepository .deleteAll ();
313
+ }
314
+ }
315
+
316
+ @ Test
317
+ void couchbaseRepositoryQuery () throws Exception {
318
+ User user = new User ("1" , "Dave" , "Wilson" );
319
+ userRepository .save (user );
320
+ String input = "findByFirstname" ;
321
+ Method method = UserRepository .class .getMethod (input , String .class );
322
+ CouchbaseQueryMethod queryMethod = new CouchbaseQueryMethod (method ,
323
+ new DefaultRepositoryMetadata (UserRepository .class ), new SpelAwareProxyProjectionFactory (),
324
+ couchbaseTemplate .getConverter ().getMappingContext ());
325
+
326
+ CouchbaseRepositoryQuery query = new CouchbaseRepositoryQuery (couchbaseTemplate , queryMethod , null );
327
+ List <User > users = (List <User >)query .execute (new String [] { "Dave" });
328
+ assertEquals (user , users .get (0 ));
329
+ }
330
+
290
331
private void sleep (int millis ) {
291
332
try {
292
333
Thread .sleep (millis ); // so they are executed out-of-order
0 commit comments