private KerberosDescriptor createKerberosDescriptor() throws AmbariException {
    String json = "{" +
        "  \"services\": [" +
        "    {" +
        "      \"name\": \"EXISTING_SERVICE\"," +
        "      \"components\": [" +
        "        {" +
        "          \"name\": \"EXISTING_SERVICE_MASTER\"," +
        "          \"identities\": [" +
        "            {" +
        "              \"name\": \"existing_service_principal\"," +
        "              \"principal\": {" +
        "                \"value\": \"${existing-service-env/service_user}/_HOST@${realm}\"," +
        "                \"type\": \"service\"," +
        "                \"configuration\": \"existing-service-env/service_principal_name\"," +
        "                \"local_username\": \"${existing-service-env/service_user}\"" +
        "              }," +
        "              \"keytab\": {" +
        "                \"file\": \"${keytab_dir}/existing_service.service.keytab\"," +
        "                \"owner\": {" +
        "                  \"name\": \"${existing-service-env/service_user}\"," +
        "                  \"access\": \"r\"" +
        "                }," +
        "                \"group\": {" +
        "                  \"name\": \"${cluster-env/user_group}\"," +
        "                  \"access\": \"\"" +
        "                }," +
        "                \"configuration\": \"existing-service-env/service_keytab_path\"" +
        "              }" +
        "            }" +
        "          ]," +
        "          \"configurations\": [" +
        "            {" +
        "              \"existing-service-site\": {" +
        "                \"kerberos.secured\": \"true\"" +
        "              }" +
        "            }," +
        "            {" +
        "              \"core-site\": {" +
        "                \"hadoop.proxyuser.${existing-service-env/service_user}.groups\": \"${hadoop-env/proxyuser_group}\"," +
        "                \"hadoop.proxyuser.${existing-service-env/service_user}.hosts\": \"${clusterHostInfo/existing_service_master_hosts}\"" +
        "              }" +
        "            }" +
        "          ]" +
        "        }" +
        "      ]" +
        "    }," +
        "    {" +
        "      \"name\": \"PRECONFIGURE_SERVICE\"," +
        "      \"preconfigure\": true," +
        "      \"components\": [" +
        "        {" +
        "          \"name\": \"PRECONFIGURE_SERVICE_MASTER\"," +
        "          \"identities\": [" +
        "            {" +
        "              \"name\": \"preconfigure_service_principal\"," +
        "              \"principal\": {" +
        "                \"value\": \"${preconfigure-service-env/service_user}/_HOST@${realm}\"," +
        "                \"type\": \"service\"," +
        "                \"configuration\": \"preconfigure-service-env/service_principal_name\"," +
        "                \"local_username\": \"${preconfigure-service-env/service_user}\"" +
        "              }," +
        "              \"keytab\": {" +
        "                \"file\": \"${keytab_dir}/preconfigure_service.service.keytab\"," +
        "                \"owner\": {" +
        "                  \"name\": \"${preconfigure-service-env/service_user}\"," +
        "                  \"access\": \"r\"" +
        "                }," +
        "                \"group\": {" +
        "                  \"name\": \"${cluster-env/user_group}\"," +
        "                  \"access\": \"\"" +
        "                }," +
        "                \"configuration\": \"preconfigure-service-env/service_keytab_path\"" +
        "              }" +
        "            }" +
        "          ]," +
        "          \"configurations\": [" +
        "            {" +
        "              \"preconfigure-service-site\": {" +
        "                \"kerberos.secured\": \"true\"" +
        "              }" +
        "            }," +
        "            {" +
        "              \"core-site\": {" +
        "                \"hadoop.proxyuser.${preconfigure-service-env/service_user}.groups\": \"${hadoop-env/proxyuser_group}\"," +
        "                \"hadoop.proxyuser.${preconfigure-service-env/service_user}.hosts\": \"${clusterHostInfo/preconfigure_service_master_hosts}\"" +
        "              }" +
        "            }" +
        "          ]" +
        "        }" +
        "      ]" +
        "    }" +
        "  ]" +
        "}";

    return new KerberosDescriptorFactory().createInstance(json);
  }
Test that a Kerberos Descriptor that contains a Service with 0 Components does not raise any exceptions.
ambari-server/src/test/java/org/apache/ambari/server/controller/KerberosHelperTest.java