@Test
  public void testCreateServicesMultiple() throws Exception, AuthorizationException {
    Set<ServiceRequest> set1 = new HashSet<>();

    String cluster1 = getUniqueName();

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

    ServiceRequest valid1 = new ServiceRequest(cluster1, "HDFS", repositoryVersion01.getId(), null, null);
    ServiceRequest valid2 = new ServiceRequest(cluster1, "MAPREDUCE", repositoryVersion01.getId(), null, null);
    set1.add(valid1);
    set1.add(valid2);
    ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);

    try {
      valid1 = new ServiceRequest(cluster1, "PIG", repositoryVersion01.getId(), null, null);
      valid2 = new ServiceRequest(cluster1, "MAPREDUCE", 4L, null, null);
      set1.add(valid1);
      set1.add(valid2);
      ServiceResourceProviderTest.createServices(controller, repositoryVersionDAO, set1);
      fail("Expected failure for invalid services");
    } catch (Exception e) {
      // Expected
      Assert.assertTrue(checkExceptionType(e, DuplicateResourceException.class));
    }

    Assert.assertNotNull(clusters.getCluster(cluster1));
    Assert.assertEquals(2, clusters.getCluster(cluster1).getServices().size());
    Assert.assertNotNull(clusters.getCluster(cluster1).getService("HDFS"));
    Assert.assertNotNull(clusters.getCluster(cluster1).getService("MAPREDUCE"));
  }
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