Refine search
public void testRemoveIfMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Collection<Object> keys = cache.keySet(); keys.removeIf(k -> k.equals("2")); assertCacheSize(2); }
public void testRemoveIfMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Collection<Object> values = cache.values(); values.removeIf(v -> ((String) v).startsWith("t")); assertCacheSize(1); }
public void testClearMethodOfEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Set<Map.Entry<Object, Object>> entries = cache.entrySet(); entries.clear(); assertCacheIsEmpty(); }
public void testRemoveIfMethodOfEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Set<Map.Entry<Object, Object>> entries = cache.entrySet(); entries.removeIf(e -> ((String) e.getValue()).startsWith("t")); assertCacheSize(1); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testAddMethodsForEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Set<Map.Entry<Object, Object>> entries = cache.entrySet(); entries.add(createMapEntry("4", "four")); }
public void testClearMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Set<Object> keys = cache.keySet(); keys.clear(); assertCacheIsEmpty(); }
public void testRemoveAllMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<String> keyCollection = new ArrayList<>(2); keyCollection.add(key2); keyCollection.add(key3); Collection<Object> keys = cache.keySet(); keys.removeAll(keyCollection); assertCacheSize(1); }
public void testClearMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); Collection<Object> values = cache.values(); values.clear(); assertCacheIsEmpty(); }
public void testRetainAllMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<String> keyCollection = new ArrayList<>(2); keyCollection.add(key2); keyCollection.add(key3); keyCollection.add("6"); Collection<Object> keys = cache.keySet(); keys.retainAll(keyCollection); assertCacheSize(2); }
public void testRetainAllMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<String> valueCollection = new ArrayList<>(2); valueCollection.add(value1); valueCollection.add(value2); valueCollection.add("5"); Collection<Object> values = cache.values(); values.retainAll(valueCollection); assertCacheSize(2); }
public void testRemoveAllMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<String> valueCollection = new ArrayList<>(2); valueCollection.add(value1); valueCollection.add(value2); Collection<Object> values = cache.values(); values.removeAll(valueCollection); assertCacheSize(1); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void testAddMethodsForEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache(0, "replSync").putAll(m); Set<Map.Entry<Object, Object>> entries = cache(0, "replSync").entrySet(); entries.add(createMapEntry("4", "four")); }
public void testPutMap() throws Exception { Matcher<FlagAffectedCommand> matcher = getFlagMatcher(); Map<Object, Object> data = new HashMap<Object, Object>(); data.put("key", "value"); data.put("key2", "value2"); cache.putAll(data); expectSingleEntryCreated(cache, "key", "value", matcher); expectSingleEntryCreated(cache, "key2", "value2", matcher); }
public void testRemoveAllMethodOfEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<Map.Entry> entryCollection = new ArrayList<>(2); entryCollection.add(createMapEntry(key1, value1)); entryCollection.add(createMapEntry(key3, value3)); Set<Map.Entry<Object, Object>> entries = cache.entrySet(); entries.removeAll(entryCollection); assertCacheSize(1); }
public void testRetainAllMethodOfEntryCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache.putAll(m); List<Map.Entry> entryCollection = new ArrayList<>(3); entryCollection.add(createMapEntry(key1, value1)); entryCollection.add(createMapEntry(key3, value3)); entryCollection.add(createMapEntry("4", "5")); Set<Map.Entry<Object, Object>> entries = cache.entrySet(); entries.retainAll(entryCollection); assertCacheSize(2); }
public void testRetainAllMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache(0, "replSync").putAll(m); List<String> keyCollection = new ArrayList<>(2); keyCollection.add(key2); keyCollection.add(key3); keyCollection.add("6"); Collection<Object> keys = cache(0, "replSync").keySet(); keys.retainAll(keyCollection); assertEquals(2, cache(0, "replSync").size()); }
public void testRemoveAllMethodOfKeyCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache(0, "replSync").putAll(m); List<String> keyCollection = new ArrayList<>(2); keyCollection.add(key2); keyCollection.add(key3); Collection<Object> keys = cache(0, "replSync").keySet(); keys.removeAll(keyCollection); assertEquals(1, cache(0, "replSync").size()); }
public void testRemoveAllMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache(0, "replSync").putAll(m); List<String> valueCollection = new ArrayList<>(2); valueCollection.add(value1); valueCollection.add(value2); Collection<Object> values = cache(0, "replSync").values(); values.removeAll(valueCollection); assertEquals(1, cache(0, "replSync").size()); }
public void testRetainAllMethodOfValuesCollection() { final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three"; Map<String, String> m = new HashMap<>(); m.put(key1, value1); m.put(key2, value2); m.put(key3, value3); cache(0, "replSync").putAll(m); List<String> valueCollection = new ArrayList<>(2); valueCollection.add(value1); valueCollection.add(value2); valueCollection.add("5"); Collection<Object> values = cache(0, "replSync").values(); values.retainAll(valueCollection); assertEquals(2, cache(0, "replSync").size()); }