SecureCacheImpl implements SecureCache { @Override public <K, V> V putIfAbsent(String regionName, K key, V value) { security.authorize(DATA, WRITE, regionName, key); Region<K, V> region = getRegion(regionName); V oldValue = region.putIfAbsent(key, value); return postProcess(regionName, key, oldValue); } SecureCacheImpl(InternalCache cache, Security security); @Override void getAll(String regionName, Iterable<K> keys, BiConsumer<K, V> successConsumer,
      BiConsumer<K, Exception> failureConsumer); @Override V get(String regionName, K key); @Override void put(String regionName, K key, V value); @Override void putAll(String regionName, Map<K, V> entries,
      BiConsumer<K, Exception> failureConsumer); @Override V remove(String regionName, K key); @Override Collection<String> getRegionNames(); @Override int getSize(String regionName); @Override Set<K> keySet(String regionName); @Override SecureFunctionService getFunctionService(); @Override void clear(String regionName); @Override V putIfAbsent(String regionName, K key, V value); @Override Object query(String queryString, Object[] bindParameters);  }
@Test public void putIfAbsent() { authorize(DATA, WRITE, REGION, "a"); authorizingCache.putIfAbsent(REGION, "a", "b"); verify(region).putIfAbsent("a", "b"); }
@Test public void putIfAbsentWithoutAuthorization() { assertThatThrownBy(() -> authorizingCache.putIfAbsent(REGION, "a", "b")) .isInstanceOf(NotAuthorizedException.class); }