15
15
*/
16
16
package org .springframework .data .map ;
17
17
18
+ import static org .hamcrest .collection .IsEmptyIterable .*;
18
19
import static org .hamcrest .collection .IsIterableContainingInAnyOrder .*;
19
20
import static org .hamcrest .core .Is .*;
20
21
import static org .hamcrest .core .IsEqual .*;
24
25
25
26
import java .io .Serializable ;
26
27
28
+ import org .hamcrest .collection .IsIterableContainingInAnyOrder ;
29
+ import org .hamcrest .collection .IsIterableWithSize ;
27
30
import org .junit .Before ;
28
31
import org .junit .Test ;
29
32
import org .springframework .data .keyvalue .core .KeyValueIterator ;
@@ -193,7 +196,7 @@ public void deleteShouldReturnDeletedObject() {
193
196
* @see DATAKV-99
194
197
*/
195
198
@ Test
196
- public void scanShouldIterateOverAvailableEntries () {
199
+ public void entriesShouldIterateOverAvailableEntries () {
197
200
198
201
adapter .put ("1" , object1 , COLLECTION_1 );
199
202
adapter .put ("2" , object2 , COLLECTION_1 );
@@ -209,15 +212,15 @@ public void scanShouldIterateOverAvailableEntries() {
209
212
* @see DATAKV-99
210
213
*/
211
214
@ Test
212
- public void scanShouldReturnEmptyIteratorWhenNoElementsAvailable () {
215
+ public void entriesShouldReturnEmptyIteratorWhenNoElementsAvailable () {
213
216
assertThat (adapter .entries (COLLECTION_1 ).hasNext (), is (false ));
214
217
}
215
218
216
219
/**
217
220
* @see DATAKV-99
218
221
*/
219
222
@ Test
220
- public void scanDoesNotMixResultsFromMultipleKeyspaces () {
223
+ public void entriesShouldNotMixResultsFromMultipleKeyspaces () {
221
224
222
225
adapter .put ("1" , object1 , COLLECTION_1 );
223
226
adapter .put ("2" , object2 , COLLECTION_2 );
@@ -228,6 +231,40 @@ public void scanDoesNotMixResultsFromMultipleKeyspaces() {
228
231
assertThat (iterator .hasNext (), is (false ));
229
232
}
230
233
234
+ /**
235
+ * @see DATAKV-102
236
+ */
237
+ @ Test
238
+ public void keysShouldReturnAvailableKeys () {
239
+
240
+ adapter .put ("1" , object1 , COLLECTION_1 );
241
+ adapter .put ("2" , object2 , COLLECTION_1 );
242
+
243
+ Iterable <Serializable > iterable = adapter .keys (COLLECTION_1 );
244
+
245
+ assertThat (iterable , IsIterableContainingInAnyOrder .<Serializable > containsInAnyOrder ("1" , "2" ));
246
+ }
247
+
248
+ /**
249
+ * @see DATAKV-102
250
+ */
251
+ @ Test
252
+ public void keyShouldReturnEmptyIterableWhenNoElementsAvailable () {
253
+ assertThat (adapter .keys (COLLECTION_1 ), emptyIterable ());
254
+ }
255
+
256
+ /**
257
+ * @see DATAKV-102
258
+ */
259
+ @ Test
260
+ public void keysShouldNotMixResultsFromMultipleKeyspaces () {
261
+
262
+ adapter .put ("1" , object1 , COLLECTION_1 );
263
+ adapter .put ("2" , object2 , COLLECTION_2 );
264
+
265
+ assertThat (adapter .keys (COLLECTION_1 ), IsIterableWithSize .<Serializable > iterableWithSize (1 ));
266
+ }
267
+
231
268
static class SimpleObject {
232
269
233
270
protected String stringValue ;
0 commit comments