16
16
17
17
package org .springframework .data .couchbase .repository ;
18
18
19
- import com .couchbase .client .core .error .IndexExistsException ;
19
+ import static java .util .Arrays .asList ;
20
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
21
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
22
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
23
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
24
+
25
+ import reactor .core .publisher .Flux ;
26
+ import reactor .test .StepVerifier ;
27
+
28
+ import java .util .List ;
29
+ import java .util .concurrent .Callable ;
30
+ import java .util .concurrent .ExecutorService ;
31
+ import java .util .concurrent .Executors ;
32
+ import java .util .concurrent .Future ;
33
+ import java .util .stream .Collectors ;
34
+
20
35
import org .junit .jupiter .api .BeforeEach ;
21
36
import org .junit .jupiter .api .Test ;
22
37
import org .springframework .beans .factory .annotation .Autowired ;
35
50
import org .springframework .data .couchbase .util .ClusterType ;
36
51
import org .springframework .data .couchbase .util .IgnoreWhen ;
37
52
import org .springframework .test .context .junit .jupiter .SpringJUnitConfig ;
38
- import reactor .test .StepVerifier ;
39
53
40
- import java .util .List ;
41
- import java .util .concurrent .Callable ;
42
- import java .util .concurrent .ExecutorService ;
43
- import java .util .concurrent .Executors ;
44
- import java .util .concurrent .Future ;
45
- import java .util .stream .Collectors ;
46
-
47
- import static java .util .Arrays .*;
48
- import static org .assertj .core .api .Assertions .*;
49
- import static org .junit .jupiter .api .Assertions .*;
54
+ import com .couchbase .client .core .error .IndexExistsException ;
50
55
51
56
/**
52
57
* template class for Reactive Couchbase operations
58
63
@ IgnoreWhen (missesCapabilities = Capabilities .QUERY , clusterTypes = ClusterType .MOCKED )
59
64
public class ReactiveCouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegrationTests {
60
65
61
- @ Autowired
62
- CouchbaseClientFactory clientFactory ;
66
+ @ Autowired CouchbaseClientFactory clientFactory ;
63
67
64
- @ Autowired
65
- ReactiveAirportRepository airportRepository ; // intellij flags "Could not Autowire", but it runs ok.
66
- @ Autowired
67
- ReactiveUserRepository userRepository ; // intellij flags "Could not Autowire", but it runs ok.
68
+ @ Autowired ReactiveAirportRepository airportRepository ; // intellij flags "Could not Autowire", but it runs ok.
69
+ @ Autowired ReactiveUserRepository userRepository ; // intellij flags "Could not Autowire", but it runs ok.
68
70
69
71
@ BeforeEach
70
72
void beforeEach () {
@@ -119,7 +121,7 @@ public void testCas() {
119
121
120
122
@ Test
121
123
void count () {
122
- String [] iatas = {"JFK" , "IAD" , "SFO" , "SJC" , "SEA" , "LAX" , "PHX" };
124
+ String [] iatas = { "JFK" , "IAD" , "SFO" , "SJC" , "SEA" , "LAX" , "PHX" };
123
125
Future [] future = new Future [iatas .length ];
124
126
ExecutorService executorService = Executors .newFixedThreadPool (iatas .length );
125
127
try {
@@ -128,8 +130,11 @@ void count() {
128
130
Airport airport = new Airport ("airports::" + iatas [i ], iatas [i ] /*iata*/ , iatas [i ].toLowerCase () /* lcao */ );
129
131
airportRepository .save (airport ).block ();
130
132
}
131
-
132
- Long airportCount = airportCount = airportRepository .count ().block ();
133
+ List <Airport > airports = airportRepository .findAll ().collectList ().block ();
134
+ for (Airport ap : airports ) {
135
+ System .out .println (ap );
136
+ }
137
+ Long airportCount = airportRepository .count ().block ();
133
138
assertEquals (iatas .length , airportCount );
134
139
135
140
airportCount = airportRepository .countByIataIn ("JFK" , "IAD" , "SFO" ).block ();
@@ -154,21 +159,23 @@ void count() {
154
159
}
155
160
156
161
@ Test
157
- // DATACOUCH-650
162
+ // DATACOUCH-650
158
163
void deleteAllById () {
159
164
160
165
Airport vienna = new Airport ("airports::vie" , "vie" , "LOWW" );
161
166
Airport frankfurt = new Airport ("airports::fra" , "fra" , "EDDF" );
162
167
Airport losAngeles = new Airport ("airports::lax" , "lax" , "KLAX" );
163
168
164
169
try {
165
- airportRepository .saveAll (asList (vienna , frankfurt , losAngeles )).as (StepVerifier ::create ).verifyComplete ();
170
+ airportRepository .saveAll (asList (vienna , frankfurt , losAngeles )).as (StepVerifier ::create )
171
+ .expectNext (vienna , frankfurt , losAngeles ).verifyComplete ();
166
172
167
- airportRepository .deleteAllById (asList (vienna .getId (), losAngeles .getId ())).as (StepVerifier ::create ).verifyComplete ();
173
+ airportRepository .deleteAllById (asList (vienna .getId (), losAngeles .getId ())).as (StepVerifier ::create )
174
+ .verifyComplete ();
168
175
169
176
airportRepository .findAll ().as (StepVerifier ::create ).expectNext (frankfurt ).verifyComplete ();
170
177
} finally {
171
- airportRepository .deleteAll ();
178
+ airportRepository .deleteAll (). block () ;
172
179
}
173
180
}
174
181
0 commit comments