### Question:
EquipManager extends AbstractMongoManager { public WeaponPojo getRandomWeaponByQualityAndLevel(int userLevel, int quality) { List<WeaponPojo> weapons = qualityWeapons.get(quality); WeaponPojo weapon = null; if ( weapons != null ) { int weaponCount = weapons.size(); for ( int i=0; i<weaponCount; i++ ) { if ( weaponCount > 0 ) { int randomWeaponPsedoIndex = (int)(MathUtil.nextDouble() * weapons.size()); WeaponPojo w = weapons.get(randomWeaponPsedoIndex%weaponCount); RewardLevelPojo rewardPojo = RewardManager.getInstance().getRewardLevelPojoByTypeId(w.getTypeName()); if ( rewardPojo != null && rewardPojo.isEnabled() ) { if ( rewardPojo.getMinLevel() <= userLevel ) { if ( rewardPojo.getRatio() < 1.0 ) { double r = MathUtil.nextDouble(); if ( rewardPojo.getRatio() <= r ) { weapon = w; break; } } else { weapon = w; break; } } } } } if ( weapon != null ) { String typeName = weapon.getTypeName(); weapons = this.getWeaponsByTypeName(typeName); for ( WeaponPojo w : weapons ) { if ( w.getUserLevel() > userLevel ) { break; } else { weapon = w; } } } } return weapon; } EquipManager(); static EquipManager getInstance(); void reload(); WeaponPojo getWeaponById(String id); Collection<WeaponPojo> getWeapons(); Collection<WeaponPojo> getWeaponsBySlot(EquipType equipType); final WeaponPojo getRandomWeapon(User user, EquipType equipType, int quality); final WeaponPojo getRandomWeapon(int userLevel, EquipType equipType, int quality); final WeaponPojo getRandomWeaponWithoutCheckReward(Gender gender, int userLevel, EquipType equipType, int quality); List<WeaponPojo> getWeaponsByTypeName(String typeName); WeaponPojo getWeaponByTypeNameAndUserLevel(String typeName, int userLevel); WeaponPojo getRandomWeaponByGenderAndLevel(Gender gender, User user); WeaponPojo getRandomWeaponByGenderAndLevel(Gender gender, int userLevel); WeaponPojo getRandomWeaponByQualityAndLevel(int userLevel, int quality); boolean checkWeaponLevelForUser(User user, String weaponId); BseEquipment toBseEquipment(); BseZip toBseZip();  }### Answer:
@Test public void testGetRandomWeaponByQualityAndLevel() { EquipManager manager = EquipManager.getInstance(); int userLevel = 20; int count = 1000; HashSet<String> set = new HashSet<String>(); for ( int i=0; i<count; i++ ) { WeaponPojo weapon = manager.getRandomWeaponByQualityAndLevel(20, 2); set.add(weapon.getName()); } for ( String name : set ) { System.out.println(name); } }