@Test(expected = IllegalArgumentException.class) public void yamlFile_shouldExist() { new YamlParser().parseConfigurationFile(null); }
@Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile = safeYaml.load(inputStream); Map<?,?> ff4jYamlMap = (Map<?, ?>) yamlConfigFile.get(FF4J_TAG); FF4jConfiguration ff4jConfig = new FF4jConfiguration(); if (ff4jYamlMap != null) { if (ff4jYamlMap.containsKey(GLOBAL_AUDIT_TAG)) { ff4jConfig.setAudit(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUDIT_TAG).toString())); } if (ff4jYamlMap.containsKey(GLOBAL_AUTOCREATE)) { ff4jConfig.setAutoCreate(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUTOCREATE).toString())); } ff4jConfig.getProperties() .putAll(parseProperties((List<Map<String, Object>>) ff4jYamlMap.get(PROPERTIES_TAG)) ); parseFeatures(ff4jConfig, (List<Map<String, Object>>) ff4jYamlMap.get(FEATURES_TAG)); } return ff4jConfig; }
YamlParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile = safeYaml.load(inputStream); Map<?,?> ff4jYamlMap = (Map<?, ?>) yamlConfigFile.get(FF4J_TAG); FF4jConfiguration ff4jConfig = new FF4jConfiguration(); if (ff4jYamlMap != null) { if (ff4jYamlMap.containsKey(GLOBAL_AUDIT_TAG)) { ff4jConfig.setAudit(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUDIT_TAG).toString())); } if (ff4jYamlMap.containsKey(GLOBAL_AUTOCREATE)) { ff4jConfig.setAutoCreate(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUTOCREATE).toString())); } ff4jConfig.getProperties() .putAll(parseProperties((List<Map<String, Object>>) ff4jYamlMap.get(PROPERTIES_TAG)) ); parseFeatures(ff4jConfig, (List<Map<String, Object>>) ff4jYamlMap.get(FEATURES_TAG)); } return ff4jConfig; } }
YamlParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile = safeYaml.load(inputStream); Map<?,?> ff4jYamlMap = (Map<?, ?>) yamlConfigFile.get(FF4J_TAG); FF4jConfiguration ff4jConfig = new FF4jConfiguration(); if (ff4jYamlMap != null) { if (ff4jYamlMap.containsKey(GLOBAL_AUDIT_TAG)) { ff4jConfig.setAudit(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUDIT_TAG).toString())); } if (ff4jYamlMap.containsKey(GLOBAL_AUTOCREATE)) { ff4jConfig.setAutoCreate(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUTOCREATE).toString())); } ff4jConfig.getProperties() .putAll(parseProperties((List<Map<String, Object>>) ff4jYamlMap.get(PROPERTIES_TAG)) ); parseFeatures(ff4jConfig, (List<Map<String, Object>>) ff4jYamlMap.get(FEATURES_TAG)); } return ff4jConfig; } YamlParser(); }
YamlParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile = safeYaml.load(inputStream); Map<?,?> ff4jYamlMap = (Map<?, ?>) yamlConfigFile.get(FF4J_TAG); FF4jConfiguration ff4jConfig = new FF4jConfiguration(); if (ff4jYamlMap != null) { if (ff4jYamlMap.containsKey(GLOBAL_AUDIT_TAG)) { ff4jConfig.setAudit(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUDIT_TAG).toString())); } if (ff4jYamlMap.containsKey(GLOBAL_AUTOCREATE)) { ff4jConfig.setAutoCreate(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUTOCREATE).toString())); } ff4jConfig.getProperties() .putAll(parseProperties((List<Map<String, Object>>) ff4jYamlMap.get(PROPERTIES_TAG)) ); parseFeatures(ff4jConfig, (List<Map<String, Object>>) ff4jYamlMap.get(FEATURES_TAG)); } return ff4jConfig; } YamlParser(); @Override InputStream export(FF4jConfiguration ff4jConfig); @Override @SuppressWarnings("unchecked") FF4jConfiguration parseConfigurationFile(InputStream inputStream); }
YamlParser implements FF4jConfigurationParser<FF4jConfiguration> { @Override @SuppressWarnings("unchecked") public FF4jConfiguration parseConfigurationFile(InputStream inputStream) { Util.assertNotNull(inputStream, "Cannot read file stream is empty, check readability and path."); Map<?,?> yamlConfigFile = safeYaml.load(inputStream); Map<?,?> ff4jYamlMap = (Map<?, ?>) yamlConfigFile.get(FF4J_TAG); FF4jConfiguration ff4jConfig = new FF4jConfiguration(); if (ff4jYamlMap != null) { if (ff4jYamlMap.containsKey(GLOBAL_AUDIT_TAG)) { ff4jConfig.setAudit(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUDIT_TAG).toString())); } if (ff4jYamlMap.containsKey(GLOBAL_AUTOCREATE)) { ff4jConfig.setAutoCreate(Boolean.valueOf(ff4jYamlMap.get(GLOBAL_AUTOCREATE).toString())); } ff4jConfig.getProperties() .putAll(parseProperties((List<Map<String, Object>>) ff4jYamlMap.get(PROPERTIES_TAG)) ); parseFeatures(ff4jConfig, (List<Map<String, Object>>) ff4jYamlMap.get(FEATURES_TAG)); } return ff4jConfig; } YamlParser(); @Override InputStream export(FF4jConfiguration ff4jConfig); @Override @SuppressWarnings("unchecked") FF4jConfiguration parseConfigurationFile(InputStream inputStream);  }