// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// @SuppressWarnings("PMD.UselessParentheses")
// public static String asConfigKey(String path) {
//   return ((path != null) && !path.startsWith("\"") && path.contains("."))
//       ? "\"" + path + "\""
//       : path;
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// public static String asConfigPath(String key) {
//   return stripQuotes(key);
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// public static Map<String, String> getStringMap(Config config, String key) {
//   ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
//   try {
//     for (String value : config.getStringList(key)) {
//       builder.put(value, value);
//     }
//   } catch (ConfigException.WrongType e) {
//     Config nestedConfig = config.getConfig(key);
//     for (Map.Entry<String, ConfigValue> entry : nestedConfig.root().entrySet()) {
//       String nestedKey = entry.getKey();
//       String quotelessKey = stripQuotes(nestedKey);
//       try {
//         builder.put(quotelessKey, nestedConfig.getString(nestedKey));
//       } catch (ConfigException.WrongType ignore) {
//         LOG.warn("Ignoring non-string-valued key: '{}'", quotelessKey);
//       }
//     }
//   }
//   return builder.build();
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// @SuppressWarnings("PMD.UselessParentheses")
// public static String stripQuotes(String key) {
//   return ((key != null) && key.startsWith("\"") && (key.length() > 1) && key.endsWith("\""))
//       ? key.substring(1, key.length() - 1)
//       : key;
// }


import static com.cloudera.director.aws.common.HoconConfigUtils.asConfigKey;
import static com.cloudera.director.aws.common.HoconConfigUtils.asConfigPath;
import static com.cloudera.director.aws.common.HoconConfigUtils.getStringMap;
import static com.cloudera.director.aws.common.HoconConfigUtils.stripQuotes;
import com.cloudera.director.aws.shaded.com.typesafe.config.Config;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigException;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.MapEntry.entry;
import static org.junit.Assert.fail;
import org.junit.Test;
// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.aws.common;



/**
 * Tests {@code ConfigUtils}.
 */
public class HoconConfigUtilsTest {

  @Test
  public void testAsConfigKey() {
    assertThat(asConfigKey(null)).isNull();
    assertThat(asConfigKey("")).isEqualTo("");
    assertThat(asConfigKey("\"")).isEqualTo("\"");
    assertThat(asConfigKey("a")).isEqualTo("a");
    assertThat(asConfigKey("a.b")).isEqualTo("\"a.b\"");
    assertThat(asConfigKey("\"a.b\"")).isEqualTo("\"a.b\"");
  }

  @Test
  public void testAsConfigPath() {
    assertThat(asConfigPath(null)).isNull();
    assertThat(asConfigPath("")).isEqualTo("");
    assertThat(asConfigPath("a")).isEqualTo("a");
    assertThat(asConfigPath("\"")).isEqualTo("\"");
    assertThat(asConfigPath("\"a")).isEqualTo("\"a");
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// @SuppressWarnings("PMD.UselessParentheses")
// public static String asConfigKey(String path) {
//   return ((path != null) && !path.startsWith("\"") && path.contains("."))
//       ? "\"" + path + "\""
//       : path;
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// public static String asConfigPath(String key) {
//   return stripQuotes(key);
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// public static Map<String, String> getStringMap(Config config, String key) {
//   ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
//   try {
//     for (String value : config.getStringList(key)) {
//       builder.put(value, value);
//     }
//   } catch (ConfigException.WrongType e) {
//     Config nestedConfig = config.getConfig(key);
//     for (Map.Entry<String, ConfigValue> entry : nestedConfig.root().entrySet()) {
//       String nestedKey = entry.getKey();
//       String quotelessKey = stripQuotes(nestedKey);
//       try {
//         builder.put(quotelessKey, nestedConfig.getString(nestedKey));
//       } catch (ConfigException.WrongType ignore) {
//         LOG.warn("Ignoring non-string-valued key: '{}'", quotelessKey);
//       }
//     }
//   }
//   return builder.build();
// }
// 
// Path: provider/src/main/java/com/cloudera/director/aws/common/HoconConfigUtils.java
// @SuppressWarnings("PMD.UselessParentheses")
// public static String stripQuotes(String key) {
//   return ((key != null) && key.startsWith("\"") && (key.length() > 1) && key.endsWith("\""))
//       ? key.substring(1, key.length() - 1)
//       : key;
// }


// Path: tests/src/test/java/com/cloudera/director/aws/common/HoconConfigUtilsTest.java
import static com.cloudera.director.aws.common.HoconConfigUtils.asConfigKey;
import static com.cloudera.director.aws.common.HoconConfigUtils.asConfigPath;
import static com.cloudera.director.aws.common.HoconConfigUtils.getStringMap;
import static com.cloudera.director.aws.common.HoconConfigUtils.stripQuotes;
import com.cloudera.director.aws.shaded.com.typesafe.config.Config;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigException;
import com.cloudera.director.aws.shaded.com.typesafe.config.ConfigFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.MapEntry.entry;
import static org.junit.Assert.fail;
import org.junit.Test;

// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.cloudera.director.aws.common;



/**
 * Tests {@code ConfigUtils}.
 */
public class HoconConfigUtilsTest {

  @Test
  public void testAsConfigKey() {
    assertThat(asConfigKey(null)).isNull();
    assertThat(asConfigKey("")).isEqualTo("");
    assertThat(asConfigKey("\"")).isEqualTo("\"");
    assertThat(asConfigKey("a")).isEqualTo("a");
    assertThat(asConfigKey("a.b")).isEqualTo("\"a.b\"");
    assertThat(asConfigKey("\"a.b\"")).isEqualTo("\"a.b\"");
  }

  @Test
  public void testAsConfigPath() {
    assertThat(asConfigPath(null)).isNull();
    assertThat(asConfigPath("")).isEqualTo("");
    assertThat(asConfigPath("a")).isEqualTo("a");
    assertThat(asConfigPath("\"")).isEqualTo("\"");
    assertThat(asConfigPath("\"a")).isEqualTo("\"a");
    assertThat(asConfigPath("\"a.b\"")).isEqualTo("a.b");