15
15
*/
16
16
package org .springframework .data .mongodb .repository .query ;
17
17
18
- import static org .hamcrest .CoreMatchers .*;
18
+ import static org .hamcrest .Matchers .*;
19
19
import static org .junit .Assert .*;
20
20
import static org .mockito .Matchers .*;
21
21
import static org .mockito .Mockito .*;
@@ -100,8 +100,7 @@ public void testDeleteExecutionCallsRemoveCorreclty() {
100
100
101
101
createQueryForMethod ("deletePersonByLastname" , String .class ).setDeleteQuery (true ).execute (new Object [] { "booh" });
102
102
103
- verify (this .mongoOperationsMock , times (1 )).remove (Matchers .any (Query .class ), Matchers .eq (Person .class ),
104
- Matchers .eq ("persons" ));
103
+ verify (this .mongoOperationsMock , times (1 )).remove (Matchers .any (Query .class ), eq (Person .class ), eq ("persons" ));
105
104
verify (this .mongoOperationsMock , times (0 )).find (Matchers .any (Query .class ), Matchers .any (Class .class ),
106
105
Matchers .anyString ());
107
106
}
@@ -119,8 +118,8 @@ public void testDeleteExecutionLoadsListOfRemovedDocumentsWhenReturnTypeIsCollec
119
118
120
119
createQueryForMethod ("deleteByLastname" , String .class ).setDeleteQuery (true ).execute (new Object [] { "booh" });
121
120
122
- verify (this .mongoOperationsMock , times (1 )).findAllAndRemove (Matchers .any (Query .class ), Matchers . eq (Person .class ),
123
- Matchers . eq ("persons" ));
121
+ verify (this .mongoOperationsMock , times (1 )).findAllAndRemove (Matchers .any (Query .class ), eq (Person .class ),
122
+ eq ("persons" ));
124
123
}
125
124
126
125
/**
@@ -143,15 +142,14 @@ public void testDeleteExecutionReturnsZeroWhenWriteResultIsNull() {
143
142
public void testDeleteExecutionReturnsNrDocumentsDeletedFromWriteResult () {
144
143
145
144
when (writeResultMock .getN ()).thenReturn (100 );
146
- when (this .mongoOperationsMock .remove (Matchers .any (Query .class ), Matchers . eq (Person .class ), Matchers . eq ("persons" )))
147
- . thenReturn ( writeResultMock );
145
+ when (this .mongoOperationsMock .remove (Matchers .any (Query .class ), eq (Person .class ), eq ("persons" ))). thenReturn (
146
+ writeResultMock );
148
147
149
148
MongoQueryFake query = createQueryForMethod ("deletePersonByLastname" , String .class );
150
149
query .setDeleteQuery (true );
151
150
152
151
assertThat (query .execute (new Object [] { "fake" }), is ((Object ) 100L ));
153
- verify (this .mongoOperationsMock , times (1 )).remove (Matchers .any (Query .class ), Matchers .eq (Person .class ),
154
- Matchers .eq ("persons" ));
152
+ verify (this .mongoOperationsMock , times (1 )).remove (Matchers .any (Query .class ), eq (Person .class ), eq ("persons" ));
155
153
}
156
154
157
155
/**
@@ -165,8 +163,7 @@ public void metadataShouldNotBeAddedToQueryWhenNotPresent() {
165
163
166
164
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
167
165
168
- verify (this .mongoOperationsMock , times (1 ))
169
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
166
+ verify (this .mongoOperationsMock , times (1 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
170
167
171
168
assertThat (captor .getValue ().getMeta ().getComment (), nullValue ());
172
169
}
@@ -182,8 +179,7 @@ public void metadataShouldBeAddedToQueryCorrectly() {
182
179
183
180
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
184
181
185
- verify (this .mongoOperationsMock , times (1 ))
186
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
182
+ verify (this .mongoOperationsMock , times (1 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
187
183
assertThat (captor .getValue ().getMeta ().getComment (), is ("comment" ));
188
184
}
189
185
@@ -198,7 +194,7 @@ public void metadataShouldBeAddedToCountQueryCorrectly() {
198
194
199
195
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
200
196
201
- verify (this .mongoOperationsMock , times (1 )).count (captor .capture (), Matchers . eq ("persons" ));
197
+ verify (this .mongoOperationsMock , times (1 )).count (captor .capture (), eq ( Person . class ), eq ("persons" ));
202
198
assertThat (captor .getValue ().getMeta ().getComment (), is ("comment" ));
203
199
}
204
200
@@ -213,8 +209,7 @@ public void metadataShouldBeAddedToStringBasedQueryCorrectly() {
213
209
214
210
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
215
211
216
- verify (this .mongoOperationsMock , times (1 ))
217
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
212
+ verify (this .mongoOperationsMock , times (1 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
218
213
assertThat (captor .getValue ().getMeta ().getComment (), is ("comment" ));
219
214
}
220
215
@@ -233,8 +228,7 @@ public void slicedExecutionShouldRetainNrOfElementsToSkip() {
233
228
234
229
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
235
230
236
- verify (this .mongoOperationsMock , times (2 ))
237
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
231
+ verify (this .mongoOperationsMock , times (2 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
238
232
239
233
assertThat (captor .getAllValues ().get (0 ).getSkip (), is (0 ));
240
234
assertThat (captor .getAllValues ().get (1 ).getSkip (), is (10 ));
@@ -255,8 +249,7 @@ public void slicedExecutionShouldIncrementLimitByOne() {
255
249
256
250
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
257
251
258
- verify (this .mongoOperationsMock , times (2 ))
259
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
252
+ verify (this .mongoOperationsMock , times (2 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
260
253
261
254
assertThat (captor .getAllValues ().get (0 ).getLimit (), is (11 ));
262
255
assertThat (captor .getAllValues ().get (1 ).getLimit (), is (11 ));
@@ -277,8 +270,7 @@ public void slicedExecutionShouldRetainSort() {
277
270
278
271
ArgumentCaptor <Query > captor = ArgumentCaptor .forClass (Query .class );
279
272
280
- verify (this .mongoOperationsMock , times (2 ))
281
- .find (captor .capture (), Matchers .eq (Person .class ), Matchers .eq ("persons" ));
273
+ verify (this .mongoOperationsMock , times (2 )).find (captor .capture (), eq (Person .class ), eq ("persons" ));
282
274
283
275
DBObject expectedSortObject = new BasicDBObjectBuilder ().add ("bar" , -1 ).get ();
284
276
assertThat (captor .getAllValues ().get (0 ).getSortObject (), is (expectedSortObject ));
0 commit comments