public void testPopulateResources_resourcemanager_clustermetrics() throws Exception {

    String[] metrics = new String[]{
      "metrics/yarn/ClusterMetrics/NumActiveNMs",
      "metrics/yarn/ClusterMetrics/NumDecommissionedNMs",
      "metrics/yarn/ClusterMetrics/NumLostNMs",
      "metrics/yarn/ClusterMetrics/NumUnhealthyNMs",
      "metrics/yarn/ClusterMetrics/NumRebootedNMs"
    };

    org.apache.ambari.server.controller.metrics.ganglia.TestStreamProvider streamProvider =
      new org.apache.ambari.server.controller.metrics.ganglia.TestStreamProvider("yarn_ganglia_data.txt");

    TestJMXProvider jmxHostProvider = new TestJMXProvider(true);
    TestGangliaHostProvider hostProvider = new TestGangliaHostProvider();
    TestGangliaServiceProvider serviceProvider = new TestGangliaServiceProvider();

    StackDefinedPropertyProvider propertyProvider = new StackDefinedPropertyProvider(
      Resource.Type.HostComponent,
      jmxHostProvider,
      hostProvider,
      serviceProvider,
      streamProvider,
      PropertyHelper.getPropertyId("HostRoles", "cluster_name"),
      PropertyHelper.getPropertyId("HostRoles", "host_name"),
      PropertyHelper.getPropertyId("HostRoles", "component_name"),
      PropertyHelper.getPropertyId("HostRoles", "state"),
      new EmptyPropertyProvider(),
      new EmptyPropertyProvider());

    for (String metric : metrics) {
      Resource resource = new ResourceImpl(Resource.Type.HostComponent);

      resource.setProperty("HostRoles/cluster_name", "c2");
      resource.setProperty(HOST_COMPONENT_HOST_NAME_PROPERTY_ID, "ip-10-39-113-33.ec2.internal");
      resource.setProperty(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID, "RESOURCEMANAGER");

      // only ask for one property
      Map<String, TemporalInfo> temporalInfoMap = new HashMap<>();
      temporalInfoMap.put(metric, new TemporalInfoImpl(10L, 20L, 1L));
      Request request = PropertyHelper.getReadRequest(Collections.singleton(metric), temporalInfoMap);

      Assert.assertEquals(1, propertyProvider.populateResources(Collections.singleton(resource), request, null).size());

      Assert.assertEquals(4, PropertyHelper.getProperties(resource).size());
      Assert.assertNotNull(resource.getPropertyValue(metric));

    }

  }
Test singleton accessor.  Public since instantiated via reflection.
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/StackDefinedPropertyProviderTest.java