@Test
  public void testAlertsJson() throws Exception {
    ServiceInfo svc = metaInfo.getService(STACK_NAME_HDP, "2.0.5", "HDFS");
    Assert.assertNotNull(svc);
    Assert.assertNotNull(svc.getAlertsFile());

    svc = metaInfo.getService(STACK_NAME_HDP, "2.0.6", "HDFS");
    Assert.assertNotNull(svc);
    Assert.assertNotNull(svc.getAlertsFile());

    svc = metaInfo.getService(STACK_NAME_HDP, "1.3.4", "HDFS");
    Assert.assertNotNull(svc);
    Assert.assertNull(svc.getAlertsFile());

    Set<AlertDefinition> set = metaInfo.getAlertDefinitions(STACK_NAME_HDP,
        "2.0.5", "HDFS");
    Assert.assertNotNull(set);
    Assert.assertTrue(set.size() > 0);

    // find two different definitions and test each one
    AlertDefinition nameNodeProcess = null;
    AlertDefinition nameNodeCpu = null;
    AlertDefinition datanodeStorage = null;
    AlertDefinition ignoreHost = null;

    Iterator<AlertDefinition> iterator = set.iterator();
    while (iterator.hasNext()) {
      AlertDefinition definition = iterator.next();
      if (definition.getName().equals("namenode_process")) {
        nameNodeProcess = definition;
      }

      if (definition.getName().equals("namenode_cpu")) {
        nameNodeCpu = definition;
      }

      if (definition.getName().equals("datanode_storage")) {
        datanodeStorage = definition;
      }

      if (definition.getName().equals("hdfs_ignore_host_test")) {
        ignoreHost = definition;
      }
    }

    assertNotNull(nameNodeProcess);
    assertNotNull(nameNodeCpu);
    assertNotNull(ignoreHost);

    assertEquals("NameNode Host CPU Utilization", nameNodeCpu.getLabel());

    // test namenode_process
    assertFalse(nameNodeProcess.isHostIgnored());
    assertEquals("A description of namenode_process", nameNodeProcess.getDescription());
    Source source = nameNodeProcess.getSource();
    assertNotNull(source);
    assertNotNull(((PortSource) source).getPort());
    Reporting reporting = source.getReporting();
    assertNotNull(reporting);
    assertNotNull(reporting.getOk());
    assertNotNull(reporting.getOk().getText());
    assertNull(reporting.getOk().getValue());
    assertNotNull(reporting.getCritical());
    assertNotNull(reporting.getCritical().getText());
    assertNull(reporting.getCritical().getValue());
    assertNull(reporting.getWarning());

    // test namenode_cpu
    assertFalse(nameNodeCpu.isHostIgnored());
    assertEquals("A description of namenode_cpu", nameNodeCpu.getDescription());
    source = nameNodeCpu.getSource();
    assertNotNull(source);
    reporting = source.getReporting();
    assertNotNull(reporting);
    assertNotNull(reporting.getOk());
    assertNotNull(reporting.getOk().getText());
    assertNull(reporting.getOk().getValue());
    assertNotNull(reporting.getCritical());
    assertNotNull(reporting.getCritical().getText());
    assertNotNull(reporting.getCritical().getValue());
    assertNotNull(reporting.getWarning());
    assertNotNull(reporting.getWarning().getText());
    assertNotNull(reporting.getWarning().getValue());

    // test a metric alert
    assertNotNull(datanodeStorage);
    assertEquals("A description of datanode_storage", datanodeStorage.getDescription());
    assertFalse(datanodeStorage.isHostIgnored());
    MetricSource metricSource = (MetricSource) datanodeStorage.getSource();
    assertNotNull( metricSource.getUri() );
    assertNotNull( metricSource.getUri().getHttpsProperty() );
    assertNotNull( metricSource.getUri().getHttpsPropertyValue() );
    assertNotNull( metricSource.getUri().getHttpsUri() );
    assertNotNull( metricSource.getUri().getHttpUri() );
    assertEquals(12345, metricSource.getUri().getDefaultPort().intValue());
//
    // ignore host
    assertTrue(ignoreHost.isHostIgnored());
  }
Make sure global mapping is avaliable when global.xml is
in the path.
ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaInfoTest.java