Guava MapMaker

This commit is contained in:
ramkumarvenkat 2020-03-10 16:35:00 +05:30
parent 335127f269
commit 9860318a48
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
package com.baeldung.guava.mapmaker;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertEquals;
import com.google.common.collect.MapMaker;
import org.junit.Test;
import java.util.concurrent.ConcurrentMap;
public class GuavaMapMakerUnitTest {
@Test
public void whenMakeMap_thenCreated() {
ConcurrentMap<String, String> m = new MapMaker()
.makeMap();
assertNotNull(m);
}
@Test
public void whenMakeMapWithWeakKeys_thenCreated() {
ConcurrentMap<String, String> m = new MapMaker()
.weakKeys()
.makeMap();
assertNotNull(m);
}
@Test
public void whenMakeMapWithWeakValues_thenCreated() {
ConcurrentMap<String, String> m = new MapMaker()
.weakValues()
.makeMap();
assertNotNull(m);
}
@Test
public void whenMakeMapWithInitialCapacity_thenCreated() {
ConcurrentMap<String, String> m = new MapMaker()
.initialCapacity(10)
.makeMap();
assertNotNull(m);
}
@Test
public void whenMakeMapWithConcurrencyLevel_thenCreated() {
ConcurrentMap<String, String> m = new MapMaker()
.concurrencyLevel(10)
.makeMap();
assertNotNull(m);
}
}