SentinelServiceImpl extends AbstractConsoleService<SetinelTblDao> implements SentinelService { protected SetinelTbl random(List<SetinelTbl> setinels) { Random random = new Random(); int index = random.nextInt(setinels.size()); return setinels.get(index); }  @Override List<SetinelTbl> findAllByDcName(final String dcName); @Override Map<Long, List<SetinelTbl>> allSentinelsByDc(); @Override Map<Long, SetinelTbl> eachRandomSentinelByDc(); @Override SetinelTbl find(final long id); @Override Map<Long, SetinelTbl> findByShard(long shardId); @Override SetinelTbl insert(SetinelTbl setinelTbl); @Override Map<String, SentinelUsageModel> getAllSentinelsUsage(); @Override SentinelModel updateSentinelTblAddr(SentinelModel sentinel); @Override RetMessage removeSentinelMonitor(String clusterName); @Override void delete(long id); @Override void reheal(long id);  }
@Test public void testRandom() { int testCount = 1 << 10; Set<Long> all = new HashSet<>(); for (int i = 0; i < testCount; i++) { SetinelTbl random = sentinelService.random(sentinels); all.add(random.getSetinelId()); } Assert.assertEquals(sentinels.size(), all.size()); }