private void testMapOperationResult(BiFunction<LocalMap<String, ShareableObject>, String, ShareableObject> operation) { final String key = "key"; final ShareableObject value = new ShareableObject("some test data"); final LocalMap<String, ShareableObject> map = vertx.sharedData().getLocalMap("foo"); assertNull(map.put(key, value)); final ShareableObject result = operation.apply(map, key); assertEquals(value, result); assertNotSame(value, result); }
assertNull(map.putIfAbsent("foo", "there")); assertNotNull(map.putIfAbsent("foo", "there")); assertEquals(map.getOrDefault("foo", "miss"), "there"); assertEquals(map.get("foo"), "there"); assertNull(map.get("missing")); assertTrue(map.removeIfPresent("foo", "there")); assertNull(map.put("foo", "there")); assertFalse(map.replaceIfPresent("missing", "nope", "something")); assertTrue(map.replaceIfPresent("foo", "there", "something"));
private void testMapOperationResult(BiFunction<LocalMap<String, ShareableObject>, String, ShareableObject> operation) { final String key = "key"; final ShareableObject value = new ShareableObject("some test data"); final LocalMap<String, ShareableObject> map = vertx.sharedData().getLocalMap("foo"); assertNull(map.put(key, value)); final ShareableObject result = operation.apply(map, key); assertEquals(value, result); assertNotSame(value, result); }
assertNull(map.putIfAbsent("foo", "there")); assertNotNull(map.putIfAbsent("foo", "there")); assertEquals(map.getOrDefault("foo", "miss"), "there"); assertEquals(map.get("foo"), "there"); assertNull(map.get("missing")); assertTrue(map.removeIfPresent("foo", "there")); assertNull(map.put("foo", "there")); assertFalse(map.replaceIfPresent("missing", "nope", "something")); assertTrue(map.replaceIfPresent("foo", "there", "something"));