@Test
 public void containsEntry() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, Integer> multiMap = hClient.getMultiMap("containsEntry");
   assertFalse(multiMap.containsEntry("a", 1));
   assertTrue(multiMap.put("a", 1));
   assertTrue(multiMap.containsEntry("a", 1));
   assertFalse(multiMap.containsEntry("a", 2));
 }
Пример #2
0
  @Test
  public void testContainsEntry() {
    final MultiMap mm = client.getMultiMap(randomString());
    mm.put("key1", "value1");

    assertTrue(mm.containsEntry("key1", "value1"));
    assertFalse(mm.containsEntry("key1", "NOT_THERE"));
    assertFalse(mm.containsEntry("NOT_THERE", "NOT_THERE"));
    assertFalse(mm.containsEntry("NOT_THERE", "value1"));
  }
 @Test
 public void testMultiMapContainsEntry() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapContainsEntry");
   map.put("Hello", "World");
   assertTrue(map.containsEntry("Hello", "World"));
 }
 @Test
 public void testTransactionAtomicity_whenMultiMapContainsEntryIsUsed_withoutTransaction()
     throws InterruptedException {
   final HazelcastInstance hz = Hazelcast.newHazelcastInstance(createConfigWithDummyTxService());
   final String name = HazelcastTestSupport.generateRandomString(5);
   Thread producerThread = startProducerThread(hz, name);
   try {
     IQueue<String> q = hz.getQueue(name);
     for (int i = 0; i < 1000; i++) {
       String id = q.poll();
       if (id != null) {
         MultiMap<Object, Object> multiMap = hz.getMultiMap(name);
         assertTrue(multiMap.containsEntry(id, MapTransactionStressTest.ProducerThread.value));
         multiMap.remove(id);
       } else {
         LockSupport.parkNanos(100);
       }
     }
   } finally {
     stopProducerThread(producerThread);
   }
 }