@Test
  public void testCreateServiceWithInvalidInfo() throws Exception, AuthorizationException {
    String cluster1 = getUniqueName();
    createCluster(cluster1);
    String serviceName = "HDFS";
    try {
      createService(cluster1, serviceName, State.INSTALLING);
      fail("Service creation should fail for invalid state");
    } catch (Exception e) {
      // Expected
    }
    try {
      clusters.getCluster(cluster1).getService(serviceName);
      fail("Service creation should have failed");
    } catch (Exception e) {
      // Expected
    }
    try {
      createService(cluster1, serviceName, State.INSTALLED);
      fail("Service creation should fail for invalid initial state");
    } catch (Exception e) {
      // Expected
    }

    createService(cluster1, serviceName, null);

    String serviceName2 = "MAPREDUCE";
    createService(cluster1, serviceName2, State.INIT);

    ServiceRequest r = new ServiceRequest(cluster1, null, null, null, null);
    Set<ServiceResponse> response = ServiceResourceProviderTest.getServices(controller, Collections.singleton(r));
    Assert.assertEquals(2, response.size());

    for (ServiceResponse svc : response) {
      Assert.assertTrue(svc.getServiceName().equals(serviceName)
          || svc.getServiceName().equals(serviceName2));
      Assert.assertEquals("HDP-0.2", svc.getDesiredStackId());
      Assert.assertEquals(State.INIT.toString(), svc.getDesiredState());
    }
  }
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