// Path: src/main/java/crawlercommons/domains/EffectiveTldFinder.java
// public static class EffectiveTLD {
// 
//     private boolean exception = false;
//     private boolean wild = false;
//     private boolean isPrivate = false;
//     private String domain = null;
//     private String idn = null;
// 
//     /**
//      * Parse one non-empty, non-comment line in the public suffix list and
//      * hold the public suffix and its properties in the created object.
//      * 
//      * @param line
//      *            non-empty, non-comment line in the public suffix list
//      * @param isPrivateDomain
//      *            whether line is in the section of &quot;PRIVATE
//      *            DOMAINS&quot; of the public suffix list
//      * @throws IllegalArgumentException
//      *             if the input line contains non-ASCII Unicode characters
//      *             prohibited in IDNs, cf. {@link IDN#toASCII(String)}
//      */
//     public EffectiveTLD(String line, boolean isPrivateDomain) throws IllegalArgumentException {
//         if (line.startsWith(EXCEPTION)) {
//             exception = true;
//             domain = line.substring(EXCEPTION.length(), line.length());
//         } else if (line.startsWith(WILD_CARD)) {
//             wild = true;
//             domain = line.substring(WILD_CARD.length(), line.length());
//         } else {
//             domain = line;
//         }
// 
//         String norm = normalizeName(domain);
//         if (!norm.equals(domain)) {
//             idn = domain;
//             domain = norm;
//         }
//         isPrivate = isPrivateDomain;
//     }
// 
//     /**
//      * Normalize a domain name: convert characters into to lowercase and
//      * encode dot-separated segments containing non-ASCII characters. Cf.
//      * {@link #asciiConvert(String)} and {@link IDN#toASCII(String)}
//      * 
//      * @param str
//      *            domain name segment
//      * @return normalized domain name containing only ASCII characters
//      * @throws IllegalArgumentException
//      *             if the input contains prohibited characters
//      */
//     private String normalizeName(String name) throws IllegalArgumentException {
//         String[] parts = name.split(DOT_REGEX);
//         String[] ary = new String[parts.length];
//         for (int i = 0; i < parts.length; i++) {
//             ary[i] = asciiConvert(parts[i]);
//         }
//         return join(ary);
//     }
// 
//     /**
//      * Generate name variants caused by Internationalized Domain Names:
//      * every IDN part of a eTLD can be replaced by its punycoded ASCII
//      * variant. For two-part IDN eTLDs this will generate 4 variants.
//      * 
//      * @return set of variant names
//      */
//     public Set<String> getNameVariants() {
//         Set<String> res = new HashSet<>();
//         if (idn == null) {
//             res.add(domain);
//             return res;
//         }
//         String[] parts = idn.split(DOT_REGEX);
//         String[] var = new String[parts.length];
//         for (int i = 0; i < parts.length; i++) {
//             if (!isAscii(parts[i])) {
//                 var[i] = IDN.toASCII(parts[i]);
//             }
//         }
//         for (int i = 0; i < parts.length; i++) {
//             Set<String> r = new HashSet<>();
//             if (res.size() > 0) {
//                 for (String p : res) {
//                     r.add(p + DOT + parts[i]);
//                 }
//             } else {
//                 r.add(parts[i]);
//             }
//             if (var[i] != null && !var[i].equals(parts[i])) {
//                 if (res.size() > 0) {
//                     for (String p : res) {
//                         r.add(p + DOT + var[i]);
//                     }
//                 } else {
//                     r.add(var[i]);
//                 }
//             }
//             res = r;
//         }
//         return res;
//     }
// 
//     /**
//      * Converts a single domain name segment (separated by dots) to ASCII if
//      * it contains non-ASCII character, cf. {@link IDN#toASCII(String)}.
//      * 
//      * @param str
//      *            domain name segment
//      * @return ASCII "Punycode" representation of the domain name segment
//      * @throws IllegalArgumentException
//      *             if the input contains prohibited characters
//      */
//     private static String asciiConvert(String str) throws IllegalArgumentException {
//         if (isAscii(str)) {
//             return str.toLowerCase(Locale.ROOT);
//         }
//         return IDN.toASCII(str);
//     }
// 
//     private static boolean isAscii(String str) {
//         char[] chars = str.toCharArray();
//         for (char c : chars) {
//             if (c > 127) {
//                 return false;
//             }
//         }
//         return true;
//     }
// 
//     public String getDomain() {
//         return domain;
//     }
// 
//     public boolean isWild() {
//         return wild;
//     }
// 
//     public boolean isException() {
//         return exception;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuffer sb = new StringBuffer("[");
//         sb.append("domain=").append(domain).append(",");
//         sb.append("wild=").append(wild).append(",");
//         sb.append("exception=").append(exception).append(",");
//         sb.append("private=").append(isPrivate).append("]");
//         return sb.toString();
//     }
// }


import crawlercommons.domains.EffectiveTldFinder.EffectiveTLD;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
 * Copyright 2016 Crawler-Commons
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package crawlercommons.domains;



public class EffectiveTldFinderTest {

    @Test
    public final void testDotComEtld() throws Exception {
// Path: src/main/java/crawlercommons/domains/EffectiveTldFinder.java
// public static class EffectiveTLD {
// 
//     private boolean exception = false;
//     private boolean wild = false;
//     private boolean isPrivate = false;
//     private String domain = null;
//     private String idn = null;
// 
//     /**
//      * Parse one non-empty, non-comment line in the public suffix list and
//      * hold the public suffix and its properties in the created object.
//      * 
//      * @param line
//      *            non-empty, non-comment line in the public suffix list
//      * @param isPrivateDomain
//      *            whether line is in the section of &quot;PRIVATE
//      *            DOMAINS&quot; of the public suffix list
//      * @throws IllegalArgumentException
//      *             if the input line contains non-ASCII Unicode characters
//      *             prohibited in IDNs, cf. {@link IDN#toASCII(String)}
//      */
//     public EffectiveTLD(String line, boolean isPrivateDomain) throws IllegalArgumentException {
//         if (line.startsWith(EXCEPTION)) {
//             exception = true;
//             domain = line.substring(EXCEPTION.length(), line.length());
//         } else if (line.startsWith(WILD_CARD)) {
//             wild = true;
//             domain = line.substring(WILD_CARD.length(), line.length());
//         } else {
//             domain = line;
//         }
// 
//         String norm = normalizeName(domain);
//         if (!norm.equals(domain)) {
//             idn = domain;
//             domain = norm;
//         }
//         isPrivate = isPrivateDomain;
//     }
// 
//     /**
//      * Normalize a domain name: convert characters into to lowercase and
//      * encode dot-separated segments containing non-ASCII characters. Cf.
//      * {@link #asciiConvert(String)} and {@link IDN#toASCII(String)}
//      * 
//      * @param str
//      *            domain name segment
//      * @return normalized domain name containing only ASCII characters
//      * @throws IllegalArgumentException
//      *             if the input contains prohibited characters
//      */
//     private String normalizeName(String name) throws IllegalArgumentException {
//         String[] parts = name.split(DOT_REGEX);
//         String[] ary = new String[parts.length];
//         for (int i = 0; i < parts.length; i++) {
//             ary[i] = asciiConvert(parts[i]);
//         }
//         return join(ary);
//     }
// 
//     /**
//      * Generate name variants caused by Internationalized Domain Names:
//      * every IDN part of a eTLD can be replaced by its punycoded ASCII
//      * variant. For two-part IDN eTLDs this will generate 4 variants.
//      * 
//      * @return set of variant names
//      */
//     public Set<String> getNameVariants() {
//         Set<String> res = new HashSet<>();
//         if (idn == null) {
//             res.add(domain);
//             return res;
//         }
//         String[] parts = idn.split(DOT_REGEX);
//         String[] var = new String[parts.length];
//         for (int i = 0; i < parts.length; i++) {
//             if (!isAscii(parts[i])) {
//                 var[i] = IDN.toASCII(parts[i]);
//             }
//         }
//         for (int i = 0; i < parts.length; i++) {
//             Set<String> r = new HashSet<>();
//             if (res.size() > 0) {
//                 for (String p : res) {
//                     r.add(p + DOT + parts[i]);
//                 }
//             } else {
//                 r.add(parts[i]);
//             }
//             if (var[i] != null && !var[i].equals(parts[i])) {
//                 if (res.size() > 0) {
//                     for (String p : res) {
//                         r.add(p + DOT + var[i]);
//                     }
//                 } else {
//                     r.add(var[i]);
//                 }
//             }
//             res = r;
//         }
//         return res;
//     }
// 
//     /**
//      * Converts a single domain name segment (separated by dots) to ASCII if
//      * it contains non-ASCII character, cf. {@link IDN#toASCII(String)}.
//      * 
//      * @param str
//      *            domain name segment
//      * @return ASCII "Punycode" representation of the domain name segment
//      * @throws IllegalArgumentException
//      *             if the input contains prohibited characters
//      */
//     private static String asciiConvert(String str) throws IllegalArgumentException {
//         if (isAscii(str)) {
//             return str.toLowerCase(Locale.ROOT);
//         }
//         return IDN.toASCII(str);
//     }
// 
//     private static boolean isAscii(String str) {
//         char[] chars = str.toCharArray();
//         for (char c : chars) {
//             if (c > 127) {
//                 return false;
//             }
//         }
//         return true;
//     }
// 
//     public String getDomain() {
//         return domain;
//     }
// 
//     public boolean isWild() {
//         return wild;
//     }
// 
//     public boolean isException() {
//         return exception;
//     }
// 
//     @Override
//     public String toString() {
//         StringBuffer sb = new StringBuffer("[");
//         sb.append("domain=").append(domain).append(",");
//         sb.append("wild=").append(wild).append(",");
//         sb.append("exception=").append(exception).append(",");
//         sb.append("private=").append(isPrivate).append("]");
//         return sb.toString();
//     }
// }


// Path: src/test/java/crawlercommons/domains/EffectiveTldFinderTest.java
import crawlercommons.domains.EffectiveTldFinder.EffectiveTLD;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
 * Copyright 2016 Crawler-Commons
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package crawlercommons.domains;



public class EffectiveTldFinderTest {

    @Test
    public final void testDotComEtld() throws Exception {
        EffectiveTLD etld = null;