@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();
assertNotNull(s);
assertTrue(s.isEmpty());
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();
}