@Test
public void testReplaceComplicatedVariables() throws AmbariException {

  Map<String, Map<String, String>> configurations = new HashMap<String, Map<String, String>>() {
    {
      put("", new HashMap<String, String>() {{
        put("host", "c6401.ambari.apache.org");
        put("realm", "EXAMPLE.COM");
      }});
    }
  };
  Assert.assertEquals("hive.metastore.local=false,hive.metastore.uris=thrift://c6401.ambari.apache.org:9083,hive.metastore.sasl.enabled=true,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse,hive.exec.mode.local.auto=false,hive.metastore.kerberos.principal=hive/_HOST@EXAMPLE.COM",
      helper.replaceVariables("hive.metastore.local=false,hive.metastore.uris=thrift://${host}:9083,hive.metastore.sasl.enabled=true,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse,hive.exec.mode.local.auto=false,hive.metastore.kerberos.principal=hive/_HOST@${realm}", configurations));
  Assert.assertEquals("Hello my realm is {EXAMPLE.COM}",
      helper.replaceVariables("Hello my realm is {${realm}}", configurations));
  Assert.assertEquals("$c6401.ambari.apache.org",
      helper.replaceVariables("$${host}", configurations));
}