@Test public void shouldNotAddToMapCacheIfKeyDoesntAlreadyExist() throws Exception { String nonexistentKey = "non-existent-key." + UUID.randomUUID(); map.get(nonexistentKey, ar -> { if (ar.succeeded()) { try { ChoosableIterable<ServerID> s = ar.result(); Map<String, ChoosableIterable<ServerID>> cache = getCacheFromMap(); // System.err.println("CACHE CONTENTS: " + cache); // check result assertNotNull(s); assertTrue(s.isEmpty()); // check cache assertNotNull(cache); assertFalse( "Map cache should not contain key " + nonexistentKey, cache.containsKey(nonexistentKey)); } catch (Exception e) { fail(e.toString()); } finally { testComplete(); } } else { fail(ar.cause().toString()); } }); await(); }