SecureCacheImpl implements SecureCache { @Override public <K, V> V get(String regionName, K key) { security.authorize(DATA, READ, regionName, key); Region<K, V> region = getRegion(regionName); V value = region.get(key); return postProcess(regionName, key, value); } 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 get() { authorize(DATA, READ, REGION, "a"); when(region.get("a")).thenReturn("value"); assertThat(authorizingCache.<String, String>get(REGION, "a")).isEqualTo("value"); }
@Test public void getWithFailure() { assertThatThrownBy(() -> authorizingCache.get(REGION, "a")) .isInstanceOf(NotAuthorizedException.class); }