@Test public void testGetSettingWithoutSetOfProperties() { SettingFactory settingFactory = new SettingFactory(); Map<String, Set<HashMap<String, String>>> properties; Setting setting = settingFactory.getSetting(createSettingWithoutSetOfProperties()); Set<HashMap<String, String>> propertyValues = setting.getSettingValue(Setting.SETTING_NAME_RECOVERY_SETTINGS); assertEquals(propertyValues.size(), 1); assertEquals(propertyValues.iterator().next().get(Setting.SETTING_NAME_RECOVERY_ENABLED), "true"); }
public static Setting getSetting(Collection<Map<String, Object>> blueprintSetting) { Map<String, Set<HashMap<String, String>>> properties = new HashMap<>(); Setting setting = new Setting(properties); if (blueprintSetting != null) { for (Map<String, Object> settingMap : blueprintSetting) { for (Map.Entry<String, Object> entry : settingMap.entrySet()) { final String[] propertyNames = entry.getKey().split("/"); Set<HashMap<String, String>> settingValue; if (entry.getValue() instanceof Set) { settingValue = (HashSet<HashMap<String, String>>)entry.getValue(); } else if (propertyNames.length > 1){ HashMap<String, String> property = new HashMap<>(); property.put(propertyNames[1], String.valueOf(entry.getValue())); settingValue = properties.get(propertyNames[0]); if (settingValue == null) { settingValue = new HashSet<>(); } settingValue.add(property); } else { throw new IllegalArgumentException("Invalid setting schema: " + String.valueOf(entry.getValue())); } properties.put(propertyNames[0], settingValue); } } } return setting; }
SettingFactory { public static Setting getSetting(Collection<Map<String, Object>> blueprintSetting) { Map<String, Set<HashMap<String, String>>> properties = new HashMap<>(); Setting setting = new Setting(properties); if (blueprintSetting != null) { for (Map<String, Object> settingMap : blueprintSetting) { for (Map.Entry<String, Object> entry : settingMap.entrySet()) { final String[] propertyNames = entry.getKey().split("/"); Set<HashMap<String, String>> settingValue; if (entry.getValue() instanceof Set) { settingValue = (HashSet<HashMap<String, String>>)entry.getValue(); } else if (propertyNames.length > 1){ HashMap<String, String> property = new HashMap<>(); property.put(propertyNames[1], String.valueOf(entry.getValue())); settingValue = properties.get(propertyNames[0]); if (settingValue == null) { settingValue = new HashSet<>(); } settingValue.add(property); } else { throw new IllegalArgumentException("Invalid setting schema: " + String.valueOf(entry.getValue())); } properties.put(propertyNames[0], settingValue); } } } return setting; } }
SettingFactory { public static Setting getSetting(Collection<Map<String, Object>> blueprintSetting) { Map<String, Set<HashMap<String, String>>> properties = new HashMap<>(); Setting setting = new Setting(properties); if (blueprintSetting != null) { for (Map<String, Object> settingMap : blueprintSetting) { for (Map.Entry<String, Object> entry : settingMap.entrySet()) { final String[] propertyNames = entry.getKey().split("/"); Set<HashMap<String, String>> settingValue; if (entry.getValue() instanceof Set) { settingValue = (HashSet<HashMap<String, String>>)entry.getValue(); } else if (propertyNames.length > 1){ HashMap<String, String> property = new HashMap<>(); property.put(propertyNames[1], String.valueOf(entry.getValue())); settingValue = properties.get(propertyNames[0]); if (settingValue == null) { settingValue = new HashSet<>(); } settingValue.add(property); } else { throw new IllegalArgumentException("Invalid setting schema: " + String.valueOf(entry.getValue())); } properties.put(propertyNames[0], settingValue); } } } return setting; }  }
SettingFactory { public static Setting getSetting(Collection<Map<String, Object>> blueprintSetting) { Map<String, Set<HashMap<String, String>>> properties = new HashMap<>(); Setting setting = new Setting(properties); if (blueprintSetting != null) { for (Map<String, Object> settingMap : blueprintSetting) { for (Map.Entry<String, Object> entry : settingMap.entrySet()) { final String[] propertyNames = entry.getKey().split("/"); Set<HashMap<String, String>> settingValue; if (entry.getValue() instanceof Set) { settingValue = (HashSet<HashMap<String, String>>)entry.getValue(); } else if (propertyNames.length > 1){ HashMap<String, String> property = new HashMap<>(); property.put(propertyNames[1], String.valueOf(entry.getValue())); settingValue = properties.get(propertyNames[0]); if (settingValue == null) { settingValue = new HashSet<>(); } settingValue.add(property); } else { throw new IllegalArgumentException("Invalid setting schema: " + String.valueOf(entry.getValue())); } properties.put(propertyNames[0], settingValue); } } } return setting; }  static Setting getSetting(Collection<Map<String, Object>> blueprintSetting); }
SettingFactory { public static Setting getSetting(Collection<Map<String, Object>> blueprintSetting) { Map<String, Set<HashMap<String, String>>> properties = new HashMap<>(); Setting setting = new Setting(properties); if (blueprintSetting != null) { for (Map<String, Object> settingMap : blueprintSetting) { for (Map.Entry<String, Object> entry : settingMap.entrySet()) { final String[] propertyNames = entry.getKey().split("/"); Set<HashMap<String, String>> settingValue; if (entry.getValue() instanceof Set) { settingValue = (HashSet<HashMap<String, String>>)entry.getValue(); } else if (propertyNames.length > 1){ HashMap<String, String> property = new HashMap<>(); property.put(propertyNames[1], String.valueOf(entry.getValue())); settingValue = properties.get(propertyNames[0]); if (settingValue == null) { settingValue = new HashSet<>(); } settingValue.add(property); } else { throw new IllegalArgumentException("Invalid setting schema: " + String.valueOf(entry.getValue())); } properties.put(propertyNames[0], settingValue); } } } return setting; }  static Setting getSetting(Collection<Map<String, Object>> blueprintSetting);  }