@Test
  public void testCreateHostSimple() throws Exception {
    String cluster1 = getUniqueName();
    String host1 = getUniqueName();
    String host2 = getUniqueName();


    HostRequest r1 = new HostRequest(host1, null);
    r1.toString();

    Set<HostRequest> requests = new HashSet<>();
    requests.add(r1);
    try {
      HostResourceProviderTest.createHosts(controller, requests);
      fail("Create host should fail for non-bootstrapped host");
    } catch (Exception e) {
      // Expected
    }

    clusters.addHost(host1);
    clusters.addHost(host2);
    setOsFamily(clusters.getHost(host1), "redhat", "5.9");
    setOsFamily(clusters.getHost(host2), "redhat", "5.9");

    HostRequest request = new HostRequest(host2, "foo");
    requests.add(request);

    try {
      HostResourceProviderTest.createHosts(controller, requests);
      fail("Create host should fail for invalid clusters");
    } catch (Exception e) {
      // Expected
    }

    request.setClusterName(cluster1);

    clusters.addCluster(cluster1, new StackId("HDP-0.1"));
    Cluster c = clusters.getCluster(cluster1);
    StackId stackId = new StackId("HDP-0.1");
    c.setDesiredStackVersion(stackId);
    c.setCurrentStackVersion(stackId);
    helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());

    HostResourceProviderTest.createHosts(controller, requests);

    Assert.assertNotNull(clusters.getHost(host1));
    Assert.assertNotNull(clusters.getHost(host2));

    Assert.assertEquals(0, clusters.getClustersForHost(host1).size());
    Assert.assertEquals(1, clusters.getClustersForHost(host2).size());

  }
Allows to set maintenanceStateHelper. For use when there is anything to test
with maintenance mode.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java