use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testMerge1.
/**
* merge adds when the given key is not present
*/
public void testMerge1() {
ConcurrentMap map = map5();
assertEquals("Y", map.merge(six, "Y", (x, y) -> "Z"));
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testCompute4.
/**
* compute removes when the given key is present and function returns null
*/
public void testCompute4() {
ConcurrentMap map = map5();
map.compute(one, (x, y) -> null);
assertFalse(map.containsKey(one));
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testMerge2.
/**
* merge replaces when the given key is present
*/
public void testMerge2() {
ConcurrentMap map = map5();
assertEquals("Z", map.merge(one, "Y", (x, y) -> "Z"));
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method map5.
/**
* Returns a new map from Integers 1-5 to Strings "A"-"E".
*/
private static ConcurrentMap map5() {
ConcurrentMap map = map();
assertTrue(map.isEmpty());
map.put(one, "A");
map.put(two, "B");
map.put(three, "C");
map.put(four, "D");
map.put(five, "E");
assertFalse(map.isEmpty());
assertEquals(5, map.size());
return map;
}
use of java.util.concurrent.ConcurrentMap in project caffeine by ben-manes.
the class ConcurrentHashMap8Test method testComputeIfPresent2.
/**
* computeIfPresent adds when the given key is not present
*/
public void testComputeIfPresent2() {
ConcurrentMap map = map5();
assertEquals("Z", map.computeIfPresent(one, (x, y) -> "Z"));
}
Aggregations