1414 */
1515package org .jnosql .diana .couchbase .key ;
1616
17+ import org .hamcrest .Matchers ;
1718import org .jnosql .diana .api .key .BucketManager ;
1819import org .jnosql .diana .api .key .BucketManagerFactory ;
1920import org .jnosql .diana .couchbase .CouchbaseUtil ;
2021import org .junit .jupiter .api .AfterAll ;
2122import org .junit .jupiter .api .BeforeEach ;
2223import org .junit .jupiter .api .Test ;
2324
25+ import java .util .Collections ;
2426import java .util .Map ;
27+ import java .util .Set ;
2528
26- import static org .junit .jupiter .api .Assertions .*;
29+ import static org .junit .jupiter .api .Assertions .assertEquals ;
30+ import static org .junit .jupiter .api .Assertions .assertFalse ;
31+ import static org .junit .jupiter .api .Assertions .assertNotNull ;
32+ import static org .junit .jupiter .api .Assertions .assertNull ;
33+ import static org .junit .jupiter .api .Assertions .assertTrue ;
34+ import static org .hamcrest .MatcherAssert .assertThat ;
2735
2836public class CouchbaseMapTest {
2937 private BucketManagerFactory entityManagerFactory ;
@@ -71,4 +79,45 @@ public void shouldVerifyExist() {
7179 }
7280
7381
82+ @ Test
83+ public void shouldRemove () {
84+ Map <String , User > vertebrates = entityManagerFactory .getMap (CouchbaseUtil .BUCKET_NAME , String .class , User .class );
85+ vertebrates .put ("mammals" , mammals );
86+ assertNotNull (vertebrates .remove ("mammals" ));
87+ assertNull (vertebrates .remove ("mammals" ));
88+ }
89+
90+ @ Test
91+ public void shouldPutAll () {
92+ Map <String , User > vertebrates = entityManagerFactory .getMap (CouchbaseUtil .BUCKET_NAME , String .class , User .class );
93+ Map <String , User > map = Collections .singletonMap ("mammals" , mammals );
94+ vertebrates .putAll (map );
95+
96+ assertFalse (vertebrates .isEmpty ());
97+ assertTrue (vertebrates .containsKey ("mammals" ));
98+ }
99+
100+ @ Test
101+ public void shouldKeySet () {
102+ Map <String , User > vertebrates = entityManagerFactory .getMap (CouchbaseUtil .BUCKET_NAME , String .class , User .class );
103+ vertebrates .put ("mammals" , mammals );
104+
105+ Set <String > keys = vertebrates .keySet ();
106+ assertFalse (keys .isEmpty ());
107+ assertTrue (keys .stream ().anyMatch (String .class ::isInstance ));
108+ }
109+
110+ @ Test
111+ public void shouldEntrySet () {
112+ Map <String , User > vertebrates = entityManagerFactory .getMap (CouchbaseUtil .BUCKET_NAME , String .class , User .class );
113+ vertebrates .put ("mammals" , mammals );
114+
115+ Set <Map .Entry <String , User >> entries = vertebrates .entrySet ();
116+ assertFalse (entries .isEmpty ());
117+ assertEquals (1 , entries .size ());
118+ Map .Entry <String , User > entry = entries .stream ().findFirst ().get ();
119+ assertEquals ("mammals" , entry .getKey ());
120+ assertEquals (mammals , entry .getValue ());
121+ }
122+
74123}
0 commit comments