BucketTargetingMap extends AbstractMap<K, V> { @Override public V putIfAbsent(final K key, final V value) { try { region.create(key, value, callbackArg); } catch (EntryExistsException e) { return (V) e.getOldValue(); } return null; } BucketTargetingMap(BucketRegion region, int bucketId); @Override Set<K> keySet(); @Override V putIfAbsent(final K key, final V value); @Override V get(final Object key); @Override V remove(final Object key); @Override boolean containsKey(final Object key); @Override V put(final K key, final V value); @Override Set<Entry<K, V>> entrySet(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); public Object callbackArg; }
@Test public void putIfAbsentUsesCallbackArg() { final BucketTargetingMap map = new BucketTargetingMap(region, 1); map.putIfAbsent("key", "value"); verify(region).create(eq("key"), eq("value"), eq(1)); }