### Question:
ParamFlowRuleUtil { static Map<Object, Integer> parseHotItems(List<ParamFlowItem> items) { if (items == null || items.isEmpty()) { return new HashMap<>(); } Map<Object, Integer> itemMap = new HashMap<>(items.size()); for (ParamFlowItem item : items) { Object value; try { value = parseItemValue(item.getObject(), item.getClassType()); } catch (Exception ex) { RecordLog.warn("[ParamFlowRuleUtil] Failed to parse value for item: " + item, ex); continue; } if (item.getCount() == null || item.getCount() < 0 || value == null) { RecordLog.warn("[ParamFlowRuleUtil] Ignoring invalid exclusion parameter item: " + item); continue; } itemMap.put(value, item.getCount()); } return itemMap; } private  ParamFlowRuleUtil(); static boolean isValidRule(ParamFlowRule rule); static boolean validClusterRuleId(Long id); static void fillExceptionFlowItems(ParamFlowRule rule); static Map<String, List<ParamFlowRule>> buildParamRuleMap(List<ParamFlowRule> list); static Map<String, List<ParamFlowRule>> buildParamRuleMap(List<ParamFlowRule> list,
                                                                     Predicate<ParamFlowRule> filter); static Map<String, List<ParamFlowRule>> buildParamRuleMap(List<ParamFlowRule> list,
                                                                     Predicate<ParamFlowRule> filter,
                                                                     boolean shouldSort); static Map<K, List<ParamFlowRule>> buildParamRuleMap(List<ParamFlowRule> list,
                                                                    Function<ParamFlowRule, K> groupFunction,
                                                                    Predicate<ParamFlowRule> filter,
                                                                    boolean shouldSort);  }### Answer:
@Test public void testParseHotParamExceptionItemsFailure() { String valueB = "Sentinel"; Integer valueC = 6; char valueD = 6; float valueE = 11.11f; ParamFlowItem itemA = new ParamFlowItem(null, 1, double.class.getName()); ParamFlowItem itemB = new ParamFlowItem(valueB, 3, null); ParamFlowItem itemE = new ParamFlowItem(String.valueOf(valueE), 3, ""); ParamFlowItem itemC = ParamFlowItem.newItem(valueC, -5); ParamFlowItem itemD = new ParamFlowItem(String.valueOf(valueD), null, char.class.getName()); List<ParamFlowItem> badItems = Arrays.asList(itemA, itemB, itemC, itemD, itemE); Map<Object, Integer> parsedItems = ParamFlowRuleUtil.parseHotItems(badItems); assertEquals(2, parsedItems.size()); assertEquals(itemB.getCount(), parsedItems.get(valueB)); assertFalse(parsedItems.containsKey(valueE)); assertEquals(itemE.getCount(), parsedItems.get(String.valueOf(valueE))); }
@Test public void testParseHotParamExceptionItemsSuccess() { assertEquals(0, ParamFlowRuleUtil.parseHotItems(null).size()); assertEquals(0, ParamFlowRuleUtil.parseHotItems(new ArrayList<ParamFlowItem>()).size()); Double valueA = 1.1d; String valueB = "Sentinel"; Integer valueC = 6; char valueD = 'c'; ParamFlowItem itemA = ParamFlowItem.newItem(valueA, 1); ParamFlowItem itemB = ParamFlowItem.newItem(valueB, 3); ParamFlowItem itemC = ParamFlowItem.newItem(valueC, 5); ParamFlowItem itemD = new ParamFlowItem().setObject(String.valueOf(valueD)) .setClassType(char.class.getName()) .setCount(7); List<ParamFlowItem> items = Arrays.asList(itemA, itemB, itemC, itemD); Map<Object, Integer> parsedItems = ParamFlowRuleUtil.parseHotItems(items); assertEquals(itemA.getCount(), parsedItems.get(valueA)); assertEquals(itemB.getCount(), parsedItems.get(valueB)); assertEquals(itemC.getCount(), parsedItems.get(valueC)); assertEquals(itemD.getCount(), parsedItems.get(valueD)); }