private Long createConfigGroup(Cluster cluster, String serviceName, String name, String tag,
                              List<String> hosts, List<Config> configs)
                              throws Exception {

    Map<Long, Host> hostMap = new HashMap<>();
    Map<String, Config> configMap = new HashMap<>();

    for (String hostname : hosts) {
      Host host = clusters.getHost(hostname);
      HostEntity hostEntity = hostDAO.findByName(hostname);
      hostMap.put(hostEntity.getHostId(), host);
    }

    for (Config config : configs) {
      configMap.put(config.getType(), config);
    }

    ConfigGroup configGroup = configGroupFactory.createNew(cluster, serviceName, name,
      tag, "", configMap, hostMap);

    configGroup.setServiceName(serviceName);

    cluster.addConfigGroup(configGroup);

    return configGroup.getId();
  }
Creates a Cluster object, along with its corresponding ClusterVersion based on the stack.
@param clusterName Cluster name
@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java