@Test public void isEmpty() { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("isEmpty"); int counter = 100; assertTrue(map.isEmpty()); for (int i = 0; i < counter; i++) { assertNull(map.put(i, i)); assertEquals(i, map.get(i)); } assertFalse(map.isEmpty()); }
@Test public void iterateOverMapEntries() { HazelcastClient hClient = getHazelcastClient(); IMap<String, String> map = hClient.getMap("iterateOverMapEntries"); map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); Set<Entry<String, String>> entrySet = map.entrySet(); assertEquals(3, entrySet.size()); Set<String> keySet = map.keySet(); for (Entry<String, String> entry : entrySet) { assertTrue(keySet.contains(entry.getKey())); assertEquals(entry.getValue(), map.get(entry.getKey())); } Iterator<Entry<String, String>> it = entrySet.iterator(); for (String key : keySet) { MapEntry mapEntry = map.getMapEntry(key); assertEquals(1, mapEntry.getHits()); } while (it.hasNext()) { it.next(); it.remove(); } assertTrue(map.isEmpty()); }