@Test
  public void testGetServices() throws Exception {
    String cluster1 = getUniqueName();

    StackId stackId = new StackId("HDP-0.1");
    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(stackId,
        stackId.getStackVersion());

    clusters.addCluster(cluster1, stackId);
    Cluster c1 = clusters.getCluster(cluster1);
    Service s1 = serviceFactory.createNew(c1, "HDFS", repositoryVersion);

    c1.addService(s1);
    s1.setDesiredState(State.INSTALLED);

    ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null);
    Set<ServiceResponse> resp = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));

    ServiceResponse resp1 = resp.iterator().next();

    Assert.assertEquals(s1.getClusterId(), resp1.getClusterId().longValue());
    Assert.assertEquals(s1.getCluster().getClusterName(), resp1.getClusterName());
    Assert.assertEquals(s1.getName(), resp1.getServiceName());
    Assert.assertEquals("HDP-0.1", s1.getDesiredStackId().getStackId());
    Assert.assertEquals(s1.getDesiredStackId().getStackId(), resp1.getDesiredStackId());
    Assert.assertEquals(State.INSTALLED.toString(), resp1.getDesiredState());

  }
Create a cluster with a service, and verify that the request tasks have the correct output log and error log paths.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java