コード例 #1
0
 @Test
 public void entrySet() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> multiMap = hClient.getMultiMap("entrySet");
   Map<String, List<String>> keyValueListMap = new HashMap<String, List<String>>();
   int count = 100;
   for (int i = 0; i < count; i++) {
     for (int j = 0; j <= i; j++) {
       String key = String.valueOf(i);
       String value = String.valueOf(j);
       multiMap.put(key, value);
       if (keyValueListMap.get(key) == null) {
         keyValueListMap.put(key, new ArrayList<String>());
       }
       keyValueListMap.get(key).add(value);
     }
   }
   assertEquals(count * (count + 1) / 2, multiMap.size());
   Set<Entry<String, String>> set = multiMap.entrySet();
   assertEquals(count * (count + 1) / 2, set.size());
   for (Iterator<Entry<String, String>> iterator = set.iterator(); iterator.hasNext(); ) {
     Entry<String, String> o = iterator.next();
     assertTrue(Integer.valueOf(o.getValue()) < count);
     assertTrue(keyValueListMap.get(o.getKey()).contains(o.getValue()));
   }
 }
コード例 #2
0
  @Test
  public void testEntrySet() {
    final int maxKeys = 14;
    final int maxValues = 3;
    final MultiMap mm = client.getMultiMap(randomString());

    for (int key = 0; key < maxKeys; key++) {
      for (int val = 0; val < maxValues; val++) {
        mm.put(key, val);
      }
    }

    assertEquals(maxKeys * maxValues, mm.entrySet().size());
  }
コード例 #3
0
 @Override
 public void removeAllForValue(final V val, final Handler<AsyncResult<Void>> completionHandler) {
   vertx.executeBlocking(
       () -> {
         for (Map.Entry<K, V> entry : map.entrySet()) {
           V v = entry.getValue();
           if (val.equals(v)) {
             map.remove(entry.getKey(), v);
           }
         }
         return null;
       },
       completionHandler);
 }
コード例 #4
0
 @Test
 public void testMultiMapEntrySet() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapEntrySet");
   map.put("Hello", "World");
   map.put("Hello", "Europe");
   map.put("Hello", "America");
   map.put("Hello", "Asia");
   map.put("Hello", "Africa");
   map.put("Hello", "Antarctica");
   map.put("Hello", "Australia");
   Set<Map.Entry<String, String>> entries = map.entrySet();
   assertEquals(7, entries.size());
   int itCount = 0;
   for (Map.Entry<String, String> entry : entries) {
     assertEquals("Hello", entry.getKey());
     itCount++;
   }
   assertEquals(7, itCount);
 }
コード例 #5
0
 @Test
 public void testEntrySet_whenEmpty() {
   final MultiMap mm = client.getMultiMap(randomString());
   assertEquals(Collections.EMPTY_SET, mm.entrySet());
 }