return;
}
Object newValue = addSetValues()[0];
Object newValue2 = (addSetValues().length == 1 ? addSetValues()[0] : addSetValues()[1]);
MapIterator it = makeFullMapIterator();
Map map = getMap();
Map confirmed = getConfirmedMap();
assertEquals(true, it.hasNext());
Object key = it.next();
Object value = it.getValue();
if (supportsSetValue() == false) {
try {
it.setValue(newValue);
fail();
} catch (UnsupportedOperationException ex) {}
return;
}
Object old = it.setValue(newValue);
confirmed.put(key, newValue);
assertSame("Key must not change after setValue", key, it.getKey());
assertSame("Value must be changed after setValue", newValue, it.getValue());
assertSame("setValue must return old value", value, old);
assertEquals("Map must contain key", true, map.containsKey(key));
// test against confirmed, as map may contain value twice
assertEquals("Map must not contain old value",
confirmed.containsValue(old), map.containsValue(old));
assertEquals("Map must contain new value", true, map.containsValue(newValue));
verify();
it.setValue(newValue); // same value - should be OK
confirmed.put(key, newValue);
assertSame("Key must not change after setValue", key, it.getKey());
assertSame("Value must be changed after setValue", newValue, it.getValue());
verify();
it.setValue(newValue2); // new value
confirmed.put(key, newValue2);
assertSame("Key must not change after setValue", key, it.getKey());
assertSame("Value must be changed after setValue", newValue2, it.getValue());
verify();
}