@Test
public void testPopulateResourcesForSingleHostMetric() throws Exception {

  setUpCommonMocks();
  TestStreamProvider streamProvider = new TestStreamProvider(SINGLE_HOST_METRICS_FILE_PATH);
  injectCacheEntryFactoryWithStreamProvider(streamProvider);
  TestMetricHostProvider metricHostProvider = new TestMetricHostProvider();
  ComponentSSLConfiguration sslConfiguration = mock(ComponentSSLConfiguration.class);
  TimelineMetricCacheProvider cacheProviderMock = EasyMock.createMock(TimelineMetricCacheProvider.class);
  TimelineMetricCache cacheMock = EasyMock.createMock(TimelineMetricCache.class);
  expect(cacheProviderMock.getTimelineMetricsCache()).andReturn(cacheMock).anyTimes();
  Map<String, Map<String, PropertyInfo>> propertyIds = PropertyHelper.getMetricPropertyIds(Resource.Type.Host);
  AMSPropertyProvider propertyProvider = new AMSHostPropertyProvider(
    propertyIds,
    streamProvider,
    sslConfiguration,
    cacheProviderMock,
    metricHostProvider,
    CLUSTER_NAME_PROPERTY_ID,
    HOST_NAME_PROPERTY_ID
  );
  Resource resource = new ResourceImpl(Resource.Type.Host);
  resource.setProperty(CLUSTER_NAME_PROPERTY_ID, "c1");
  resource.setProperty(HOST_NAME_PROPERTY_ID, "h1");
  Map<String, TemporalInfo> temporalInfoMap = new HashMap<String, TemporalInfo>();
  temporalInfoMap.put(PROPERTY_ID1, new TemporalInfoImpl(1416445244800L, 1416448936474L, 15L));
  Request request = PropertyHelper.getReadRequest(Collections.singleton(PROPERTY_ID1), temporalInfoMap);
  Set<Resource> resources =
    propertyProvider.populateResources(Collections.singleton(resource), request, null);
  Assert.assertEquals(1, resources.size());
  Resource res = resources.iterator().next();
  Map<String, Object> properties = PropertyHelper.getProperties(resources.iterator().next());
  Assert.assertNotNull(properties);
  URIBuilder uriBuilder = AMSPropertyProvider.getAMSUriBuilder("localhost", 6188, false);
  uriBuilder.addParameter("metricNames", "cpu_user");
  uriBuilder.addParameter("hostname", "h1");
  uriBuilder.addParameter("appId", "HOST");
  uriBuilder.addParameter("startTime", "1416445244800");
  uriBuilder.addParameter("endTime", "1416448936474");
  Assert.assertEquals(uriBuilder.toString(), streamProvider.getLastSpec());
  Number[][] val = (Number[][]) res.getPropertyValue(PROPERTY_ID1);
  Assert.assertNotNull("No value for property " + PROPERTY_ID1, val);
  Assert.assertEquals(111, val.length);
}