### Question:
PropertyCache extends AbstractDataCache<T> { @VisibleForTesting SelectivePropertyRefreshInputs<T> genSelectiveUpdateInput(HelixDataAccessor accessor, Map<String, T> oldCache, PropertyCache.PropertyCacheKeyFuncs<T> propertyKeyFuncs) { Set<PropertyKey> latestKeys = Sets.newHashSet(); for (String liveInstanceName : accessor.getChildNames(propertyKeyFuncs.getRootKey(accessor))) { latestKeys.add(propertyKeyFuncs.getObjPropertyKey(accessor, liveInstanceName)); } Set<PropertyKey> oldCachedKeys = Sets.newHashSet(); Map<PropertyKey, T> cachedObjs = new HashMap<>(); for (String objName : oldCache.keySet()) { PropertyKey objKey = propertyKeyFuncs.getObjPropertyKey(accessor, objName); oldCachedKeys.add(objKey); cachedObjs.put(objKey, oldCache.get(objName)); } Set<PropertyKey> cachedKeys = Sets.intersection(oldCachedKeys, latestKeys); Set<PropertyKey> reloadKeys = Sets.difference(latestKeys, cachedKeys); return new SelectivePropertyRefreshInputs<>(new ArrayList<>(reloadKeys), new ArrayList<>(cachedKeys), cachedObjs); } PropertyCache(ControlContextProvider contextProvider, String propertyDescription,
      PropertyCacheKeyFuncs<T> keyFuncs, boolean useSelectiveUpdate); void refresh(final HelixDataAccessor accessor); Map<String, T> getPropertyMap(); T getPropertyByName(String name); void setPropertyMap(Map<String, T> objMap); void setProperty(T obj); void deletePropertyByName(String name);  }### Answer:
@Test(description = "Unit test for selective cache refresh") public void testSelectivePropertyRefreshInputs() { HelixDataAccessor accessor = mock(HelixDataAccessor.class); Map<String, HelixProperty> currentCache = ImmutableMap.of("instance0", new HelixProperty("key0"), "instance1", new HelixProperty("key1")); PropertyCache.PropertyCacheKeyFuncs<HelixProperty> mockCacheKeyFuncs = new PropertyCache.PropertyCacheKeyFuncs<HelixProperty>() { @Override public PropertyKey getRootKey(HelixDataAccessor accessor) { return mock(PropertyKey.class); } @Override public PropertyKey getObjPropertyKey(HelixDataAccessor accessor, String objName) { return new PropertyKey.Builder("fake").instance(objName); } @Override public String getObjName(HelixProperty obj) { return obj.getRecord().getId(); } }; when(accessor.getChildNames(any(PropertyKey.class))) .thenReturn(ImmutableList.of("instance1", "instance2")); @SuppressWarnings("unchecked") PropertyCache<HelixProperty> propertyCache = new PropertyCache<>(MOCK_CONTROL_CONTEXT_PROVIDER, "mock property cache", mock(PropertyCache.PropertyCacheKeyFuncs.class), false); PropertyCache.SelectivePropertyRefreshInputs<HelixProperty> selectivePropertyRefreshInputs = propertyCache.genSelectiveUpdateInput(accessor, currentCache, mockCacheKeyFuncs); Assert.assertEquals(selectivePropertyRefreshInputs.getReloadKeys().size(), 1); Assert.assertEquals(selectivePropertyRefreshInputs.getReloadKeys().get(0), new PropertyKey.Builder("fake").instance("instance2")); }