@Test
  public void testCreateHostWithInvalidRequests() throws Exception {
    // unknown host
    // invalid clusters
    // duplicate host
    String host1 = getUniqueName();
    String cluster1 = getUniqueName();

    Set<HostRequest> set1 = new HashSet<>();

    try {
      set1.clear();
      HostRequest rInvalid =
          new HostRequest(host1, null);
      set1.add(rInvalid);
      HostResourceProviderTest.createHosts(controller, set1);
      fail("Expected failure for invalid host");
    } catch (Exception e) {
      // Expected
    }

    clusters.addHost(host1);

    try {
      set1.clear();
      HostRequest rInvalid =
          new HostRequest(host1, cluster1);
      set1.add(rInvalid);
      HostResourceProviderTest.createHosts(controller, set1);
      fail("Expected failure for invalid cluster");
    } catch (Exception e) {
      // Expected
    }

    clusters.addCluster(cluster1, new StackId("HDP-0.1"));

    try {
      set1.clear();
      HostRequest rInvalid1 =
          new HostRequest(host1, cluster1);
      rInvalid1.setRackInfo(UUID.randomUUID().toString());
      HostRequest rInvalid2 =
          new HostRequest(host1, cluster1);
      set1.add(rInvalid1);
      set1.add(rInvalid2);
      HostResourceProviderTest.createHosts(controller, set1);
      fail("Expected failure for dup requests");
    } catch (Exception e) {
      // Expected
    }
  }
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