AppConfigValidationFactory { @SuppressWarnings("unchecked") public static void validateConfigType(Map<String, Object> config, List<String> warningMsgList) { String jsonStr = CommonUtil.readJsonFile("whitelist.json"); Gson gson = new Gson(); List<Map<String, Map<String,List<Map<String, String>>>>> whiteList = gson.fromJson(jsonStr, List.class); validateConfigType(config, whiteList, warningMsgList); }  @SuppressWarnings("unchecked") static void validateConfigType(Map<String, Object> config, List<String> warningMsgList); @SuppressWarnings("unchecked") static ValidateResult blackListHandle(Map<String, Object> config); @SuppressWarnings("unchecked") static ValidateResult whiteListHandle(Map<String, Object> config);  }
@Test public void testConfigurationTypeValidation1() { Map<String, Object> configurations = new HashMap<String, Object>(); configurations.put("hadoop", new Object()); List<String> warningMsgList = new ArrayList<String>(); AppConfigValidationFactory.validateConfigType(configurations, warningMsgList); assertEquals(0, warningMsgList.size()); }
@Test public void testConfigurationTypeValidation2() { Map<String, Object> configurations = new HashMap<String, Object>(); configurations.put("hadoop", new Object()); configurations.put("xyz", new Object()); List<String> warningMsgList = new ArrayList<String>(); AppConfigValidationFactory.validateConfigType(configurations, warningMsgList); assertEquals(1, warningMsgList.size()); assertEquals("Warning: The type xyz is not a regular cluster configuration.", warningMsgList.get(0)); }
@Test public void testConfigurationTypeValidation3() { Map<String, Object> configurations = new HashMap<String, Object>(); configurations.put("hadoop", new Object()); configurations.put("xyz", new Object()); configurations.put("abc", new Object()); List<String> warningMsgList = new ArrayList<String>(); AppConfigValidationFactory.validateConfigType(configurations, warningMsgList); assertEquals(1, warningMsgList.size()); assertEquals("Warning: The types abc,xyz are not regular cluster configurations.", warningMsgList.get(0)); }