use of java.util.concurrent.ConcurrentHashMap in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testCompute.
/**
* compute does not replace if the function returns null
*/
public void testCompute() {
ConcurrentHashMap map = map5();
map.compute(six, (x, y) -> null);
assertFalse(map.containsKey(six));
}
use of java.util.concurrent.ConcurrentHashMap in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testComputeIfAbsent.
/**
* computeIfAbsent adds when the given key is not present
*/
public void testComputeIfAbsent() {
ConcurrentHashMap map = map5();
map.computeIfAbsent(six, (x) -> "Z");
assertTrue(map.containsKey(six));
}
use of java.util.concurrent.ConcurrentHashMap in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testComputeIfPresent2.
/**
* computeIfPresent adds when the given key is not present
*/
public void testComputeIfPresent2() {
ConcurrentHashMap map = map5();
assertEquals("Z", map.computeIfPresent(one, (x, y) -> "Z"));
}
use of java.util.concurrent.ConcurrentHashMap in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testGetMappedValue.
/**
* KeySetView.getMappedValue returns the map's mapped value
*/
public void testGetMappedValue() {
ConcurrentHashMap map = map5();
assertNull(map.keySet().getMappedValue());
try {
map.keySet(null);
shouldThrow();
} catch (NullPointerException success) {
}
ConcurrentHashMap.KeySetView set = map.keySet(one);
assertFalse(set.add(one));
assertTrue(set.add(six));
assertTrue(set.add(seven));
assertTrue(set.getMappedValue() == one);
assertTrue(map.get(one) != one);
assertTrue(map.get(six) == one);
assertTrue(map.get(seven) == one);
}
use of java.util.concurrent.ConcurrentHashMap in project mapdb by jankotek.
the class ConcurrentHashMap8Test method testComputeIfAbsent2.
/**
* computeIfAbsent does not replace if the key is already present
*/
public void testComputeIfAbsent2() {
ConcurrentHashMap map = map5();
assertEquals("A", map.computeIfAbsent(one, (x) -> "Z"));
}
Aggregations