### Question:
RequestDataConverter { public static Map<Double, List<String>> buildRatioResidenceRegionMap(List<String> residenceCityNames) { Map<String, Double> regionRatioMap = new HashMap<>(); for (String residenceCityName : residenceCityNames) { String cityCode = getCityCodeByCityName(residenceCityName); Double ratio = getRegionRatioByCityCode(cityCode); String region = getRegionByCityCode(cityCode); if (regionRatioMap.containsKey(region)) { regionRatioMap.put(region, regionRatioMap.get(region) + ratio); } else { regionRatioMap.put(region, ratio); } } Map<Double, List<String>> ratioResidenceRegionMap = new HashMap<>(); for (Map.Entry<String, Double> entry : regionRatioMap.entrySet()) { if (ratioResidenceRegionMap.containsKey(entry.getValue())) { ratioResidenceRegionMap.get(entry.getValue()).add(entry.getKey()); } else { List<String> regionList = new ArrayList<String>(); regionList.add(entry.getKey()); ratioResidenceRegionMap.put(entry.getValue(), regionList); } } return ratioResidenceRegionMap; } private  RequestDataConverter(); static String getRegionByCityCode(String cityCode); static String getRegionByCityName(String cityName); static String getCityCodeByCityName(String cityName); static Double getRegionRatioByCityCode(String cityCode); static Map<String, Double> getRegionRatioMap(TargetingChannel targetingChannel); static double getHourDayRatio(List<Integer> listOfHours); static Map<Double, List<String>> buildRatioCityCodeRegionMap(List<String> iplCityCodes); static Map<Double, List<String>> buildRatioResidenceRegionMap(List<String> residenceCityNames);  }### Answer:
@Test public void buildRatioResidenceRegionMap() { List<String> list = new ArrayList(); list.add("city1"); list.add("city11"); list.add("city3"); list.add("city14"); list.add("city13"); Map res = RequestDataConverter.buildRatioResidenceRegionMap(list); Map exp = new HashMap(); List<String> list1 = new ArrayList(), list2 = new ArrayList(), list3 = new ArrayList(); List res1 = (List) DEF_CODE_REGION_RATIO_MAP.get("1156510600"), res2 = (List) DEF_CODE_REGION_RATIO_MAP.get("1156511600"), res3 = (List) DEF_CODE_REGION_RATIO_MAP.get("1156511300"), res4 = (List) DEF_CODE_REGION_RATIO_MAP.get("1156430100"), res5 = (List) DEF_CODE_REGION_RATIO_MAP.get("1156430900"); list1.add(String.valueOf(res4.get(0))); list1.add(String.valueOf(res5.get(0))); exp.put(1D, list1); exp.put((Double) res3.get(1), Arrays.asList(String.valueOf(res3.get(0)))); Double sum = (Double) res1.get(1) + (Double) res2.get(1); exp.put(sum, Arrays.asList(String.valueOf(res1.get(0)))); assertTrue(res.equals(exp)); }