31
31
import org .junit .jupiter .api .Test ;
32
32
import org .springframework .beans .factory .annotation .Autowired ;
33
33
import org .springframework .context .annotation .Configuration ;
34
+ import org .springframework .dao .DataIntegrityViolationException ;
34
35
import org .springframework .data .couchbase .CouchbaseClientFactory ;
35
36
import org .springframework .data .couchbase .config .AbstractCouchbaseConfiguration ;
36
37
import org .springframework .data .couchbase .domain .Address ;
37
38
import org .springframework .data .couchbase .domain .Airport ;
38
39
import org .springframework .data .couchbase .domain .AirportRepository ;
40
+ import org .springframework .data .couchbase .domain .ReactiveUserRepository ;
41
+ import org .springframework .data .couchbase .domain .User ;
42
+ import org .springframework .data .couchbase .domain .UserRepository ;
39
43
import org .springframework .data .couchbase .domain .Person ;
40
44
import org .springframework .data .couchbase .domain .PersonRepository ;
41
45
import org .springframework .data .couchbase .repository .config .EnableCouchbaseRepositories ;
@@ -61,6 +65,8 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
61
65
62
66
@ Autowired AirportRepository airportRepository ;
63
67
68
+ @ Autowired UserRepository userRepository ;
69
+
64
70
@ BeforeEach
65
71
void beforeEach () {
66
72
try {
@@ -139,6 +145,17 @@ void findBySimpleProperty() {
139
145
140
146
}
141
147
148
+ @ Test
149
+ public void testCas () {
150
+ User user = new User ("1" , "Dave" , "Wilson" );
151
+ userRepository .save (user );
152
+ user .setVersion (user .getVersion () - 1 );
153
+ assertThrows (DataIntegrityViolationException .class , () -> userRepository .save (user ));
154
+ user .setVersion (0 );
155
+ userRepository .save (user );
156
+ userRepository .delete (user );
157
+ }
158
+
142
159
@ Test
143
160
void count () {
144
161
String [] iatas = { "JFK" , "IAD" , "SFO" , "SJC" , "SEA" , "LAX" , "PHX" };
@@ -153,8 +170,8 @@ void count() {
153
170
airportRepository .save (airport );
154
171
}
155
172
156
- Long count = airportRepository .countFancyExpression ( Arrays .asList ("JFK" ), Arrays .asList ("jfk" ), false );
157
- assertEquals ( 1 , count );
173
+ Long count = airportRepository .countFancyExpression (Arrays .asList ("JFK" ), Arrays .asList ("jfk" ), false );
174
+ assertEquals (1 , count );
158
175
159
176
long airportCount = airportRepository .count ();
160
177
assertEquals (7 , airportCount );
0 commit comments