SecureCacheImpl implements SecureCache { @Override public <K, V> void putAll(String regionName, Map<K, V> entries, BiConsumer<K, Exception> failureConsumer) { boolean authorized = tryAuthorizeAllKeys(DATA, WRITE, regionName); Region<K, V> region = getRegion(regionName); entries.forEach((key, value) -> { try { if (!authorized) { security.authorize(DATA, WRITE, regionName, key); } region.put(key, value); } catch (Exception e) { failureConsumer.accept(key, e); } }); } 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 putAll() { authorize(DATA, WRITE, REGION, "a"); authorize(DATA, WRITE, REGION, "c"); Map<Object, Object> entries = new HashMap<>(); entries.put("a", "b"); entries.put("c", "d"); Map<Object, Exception> exceptionValues = new HashMap<>(); authorizingCache.putAll(REGION, entries, exceptionValues::put); verify(region).put("a", "b"); verify(region).put("c", "d"); assertThat(exceptionValues).isEmpty(); }