TouchPartitionedRegionEntriesFunction implements Function, Declarable, DataSerializable { @Override @SuppressWarnings("unchecked") public void execute(FunctionContext context) { RegionFunctionContext rfc = (RegionFunctionContext) context; Set<String> keys = (Set<String>) rfc.getFilter(); Cache cache = context.getCache(); Region primaryDataSet = getLocalDataForContextViaRegionHelper(rfc); if (cache.getLogger().fineEnabled()) { String builder = "Function " + ID + " received request to touch " + primaryDataSet.getFullPath() + "->" + keys; cache.getLogger().fine(builder); } for (String key : keys) { primaryDataSet.get(key); } context.getResultSender().lastResult(true); }  @Override @SuppressWarnings("unchecked") void execute(FunctionContext context); @Override Collection<ResourcePermission> getRequiredPermissions(String regionName); @Override String getId(); @Override boolean optimizeForWrite(); @Override boolean isHA(); @Override boolean hasResult(); @Override void toData(DataOutput out); @Override void fromData(DataInput in); static final String ID; }
@Test public void executeDoesNotThrowExceptionWithProperlyDefinedContext() { doReturn(new HashSet() {}).when((RegionFunctionContext) context).getFilter(); function.execute(context); verify(primaryDataSet, times(0)).get(any()); verify(resultSender).lastResult(true); }
@Test public void executeDoesNotThrowExceptionWithProperlyDefinedContextAndMultipleKeys() { final HashSet<String> keys = new HashSet(); keys.add("Key1"); keys.add("Key2"); doReturn(keys).when((RegionFunctionContext) context).getFilter(); function.execute(context); verify(primaryDataSet, times(keys.size())).get(anyString()); verify(resultSender).lastResult(true); }