@Test
public void testGetHostsForServiceComponent() throws IOException, AmbariHttpException {

  final String componentHostsString = "{\"host_components\": [{" +
    "\"HostRoles\": {" +
    "\"cluster_name\": \"Ambari\"," +
    "\"host_name\": \"host1\"}}, {" +
    "\"HostRoles\": {" +
    "\"cluster_name\": \"Ambari\"," +
    "\"host_name\": \"host2\"}}]}";
  AmbariStreamProvider clusterStreamProvider = createNiceMock(AmbariStreamProvider.class);
  String service = "SERVICE";
  String component = "COMPONENT";
  final String clusterPath = "/api/v1/clusters/Test";
  expect(clusterStreamProvider.readFrom(eq(String.format("%s/services/%s/components/%s?" +
      "fields=host_components/HostRoles/host_name", clusterPath, service, component)),
    eq("GET"), (String) isNull(), EasyMock.<Map<String, String>>anyObject()))
    .andReturn(new ByteArrayInputStream(componentHostsString.getBytes()));
  RemoteAmbariClusterEntity entity = createNiceMock(RemoteAmbariClusterEntity.class);
  replay(clusterStreamProvider,entity);
  RemoteAmbariCluster cluster = new RemoteAmbariCluster("Test", clusterPath, clusterStreamProvider);
  List<String> hosts = cluster.getHostsForServiceComponent(service,component);
  Assert.assertEquals(2, hosts.size());
  Assert.assertEquals("host1",hosts.get(0));
  Assert.assertEquals("host2",hosts.get(1));
  verify(clusterStreamProvider, entity);
}