@Test
  public void testApplyConfigurationWithTheSameTag() throws AuthorizationException {

    final String cluster1 = getUniqueName();

    String tag = "version1";
    String type = "core-site";
    Exception exception = null;
    try {
      AmbariManagementController amc = injector.getInstance(AmbariManagementController.class);
      Clusters clusters = injector.getInstance(Clusters.class);
      Gson gson = new Gson();

      clusters.addHost("host1");
      clusters.addHost("host2");
      clusters.addHost("host3");
      Host host = clusters.getHost("host1");
      setOsFamily(host, "redhat", "6.3");
      host = clusters.getHost("host2");
      setOsFamily(host, "redhat", "6.3");
      host = clusters.getHost("host3");
      setOsFamily(host, "redhat", "6.3");

      ClusterRequest clusterRequest = new ClusterRequest(null, cluster1, "HDP-1.2.0", null);
      amc.createCluster(clusterRequest);

      Set<ServiceRequest> serviceRequests = new HashSet<>();
      serviceRequests.add(new ServiceRequest(cluster1, "HDFS", repositoryVersion120.getId(), null));

      ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);

      Type confType = new TypeToken<Map<String, String>>() {
      }.getType();

      ConfigurationRequest configurationRequest = new ConfigurationRequest(cluster1, type, tag,
          gson.fromJson("{ \"fs.default.name\" : \"localhost:8020\"}", confType), null);
      amc.createConfiguration(configurationRequest);

      amc.createConfiguration(configurationRequest);
    } catch (Exception e) {
      exception = e;
    }

    assertNotNull(exception);
    String exceptionMessage = MessageFormat.format("Configuration with tag ''{0}'' exists for ''{1}''",
        tag, type);
    assertEquals(exceptionMessage, exception.getMessage());
  }
Create a cluster with a service, and verify that the request tasks have the correct output log and error log paths.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java