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 .Airport ;
37
38
import org .springframework .data .couchbase .domain .AirportRepository ;
39
+ import org .springframework .data .couchbase .domain .ReactiveUserRepository ;
40
+ import org .springframework .data .couchbase .domain .User ;
41
+ import org .springframework .data .couchbase .domain .UserRepository ;
38
42
import org .springframework .data .couchbase .repository .config .EnableCouchbaseRepositories ;
39
43
import org .springframework .data .couchbase .util .Capabilities ;
40
44
import org .springframework .data .couchbase .util .ClusterAwareIntegrationTests ;
@@ -58,6 +62,8 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
58
62
59
63
@ Autowired AirportRepository airportRepository ;
60
64
65
+ @ Autowired UserRepository userRepository ;
66
+
61
67
@ BeforeEach
62
68
void beforeEach () {
63
69
try {
@@ -118,6 +124,17 @@ void findBySimpleProperty() {
118
124
119
125
}
120
126
127
+ @ Test
128
+ public void testCas () {
129
+ User user = new User ("1" , "Dave" , "Wilson" );
130
+ userRepository .save (user );
131
+ user .setVersion (user .getVersion () - 1 );
132
+ assertThrows (DataIntegrityViolationException .class , () -> userRepository .save (user ));
133
+ user .setVersion (0 );
134
+ userRepository .save (user );
135
+ userRepository .delete (user );
136
+ }
137
+
121
138
@ Test
122
139
void count () {
123
140
String [] iatas = { "JFK" , "IAD" , "SFO" , "SJC" , "SEA" , "LAX" , "PHX" };
@@ -132,8 +149,8 @@ void count() {
132
149
airportRepository .save (airport );
133
150
}
134
151
135
- Long count = airportRepository .countFancyExpression ( Arrays .asList ("JFK" ), Arrays .asList ("jfk" ), false );
136
- assertEquals ( 1 , count );
152
+ Long count = airportRepository .countFancyExpression (Arrays .asList ("JFK" ), Arrays .asList ("jfk" ), false );
153
+ assertEquals (1 , count );
137
154
138
155
long airportCount = airportRepository .count ();
139
156
assertEquals (7 , airportCount );
0 commit comments