### Question:
ClusterStatsManager { public Pair<Set<Long >, Integer > findModelWorkerStores(final int above) { final Set<Map.Entry<Long, Set<Long>>> values = this.leaderTable.entrySet(); if (values.isEmpty()) { return Pair.of(Collections.emptySet(), 0); } final Map.Entry<Long, Set<Long>> modelWorker = Collections.max(values, (o1, o2) -> { final int o1Val = o1.getValue() == null ? 0 : o1.getValue().size(); final int o2Val = o2.getValue() == null ? 0 : o2.getValue().size(); return Integer.compare(o1Val, o2Val); }); final int maxLeaderCount = modelWorker.getValue().size(); if (maxLeaderCount <= above) { return Pair.of(Collections.emptySet(), maxLeaderCount); } final Set<Long> modelWorkerStoreIds = new HashSet<>(); for (final Map.Entry<Long, Set<Long>> entry : values) { if (entry.getValue().size() >= maxLeaderCount) { modelWorkerStoreIds.add(entry.getKey()); } } return Pair.of(modelWorkerStoreIds, maxLeaderCount); } private  ClusterStatsManager(long clusterId); static ClusterStatsManager getInstance(final long clusterId); long getClusterId(); int regionSize(); void addOrUpdateLeader(final long storeId, final long regionId); Pair<Set<Long /* storeId */>, Integer /* leaderCount */> findModelWorkerStores(final int above); List<Pair<Long /* storeId */, Integer /* leaderCount */>> findLazyWorkerStores(final Collection<Long> storeCandidates); void addOrUpdateRegionStats(final List<Pair<Region, RegionStats>> regionStatsList); Pair<Region, RegionStats> findModelWorkerRegion(); static void invalidCache();  }### Answer:
@Test public void findModelWorkerStoresTest() { final ClusterStatsManager manager = ClusterStatsManager.getInstance(1); manager.addOrUpdateLeader(10, 101); manager.addOrUpdateLeader(10, 102); manager.addOrUpdateLeader(10, 103); manager.addOrUpdateLeader(11, 104); manager.addOrUpdateLeader(11, 105); manager.addOrUpdateLeader(12, 106); Pair<Set<Long>, Integer> result = manager.findModelWorkerStores(1); Assert.assertNotNull(result); Assert.assertEquals(1, result.getKey().size()); Assert.assertTrue(result.getKey().contains(10L)); Assert.assertEquals(Integer.valueOf(3), result.getValue()); manager.addOrUpdateLeader(11, 107); result = manager.findModelWorkerStores(1); Assert.assertNotNull(result); Assert.assertTrue(result.getKey().contains(10L)); Assert.assertTrue(result.getKey().contains(11L)); Assert.assertEquals(2, result.getKey().size()); Assert.assertEquals(Integer.valueOf(3), result.getValue()); manager.addOrUpdateLeader(11, 101); result = manager.findModelWorkerStores(2); Assert.assertNotNull(result); Assert.assertEquals(1, result.getKey().size()); Assert.assertEquals(Integer.valueOf(4), result.getValue()); }