void (String key) { String val = "val"; Map<Object, Object> map = factory.create(); Assume.assumeTrue("Adding (" + key + ", " + val + ") not supported", isSupported(() -> map.put(key, val))); Set<Object> keys = map.keySet(); Assert.assertTrue("Key not found", keys.contains(key)); Assert.assertEquals(1, keys.size()); Assume.assumeTrue("Key set is readonly", isSupported(() -> keys.clear())); Assert.assertEquals(0, keys.size()); Assert.assertEquals(0, map.size()); map.put(key, val); Assert.assertEquals(1, keys.size()); Iterator<?> it = keys.iterator(); Assert.assertEquals(key, it.next()); it.remove(); Assert.assertEquals(0, keys.size()); Assert.assertEquals(0, map.size()); map.put(key, val); keys.remove(key); Assert.assertEquals(0, keys.size()); Assert.assertEquals(0, map.size()); }