// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
// 
// 	/**
// 	 * Indicates if this Synonym is short-lived or transient, meaning that
//      * it should not be stored in the synonyms file. Transient Synonyms
//      * are not stored, need to be calculated each run time.
// 	 *
// 	 * Transient synonyms are:
// 	 *
// 	 * <ol>
// 	 *     <li>Not stored in memory.</li>
// 	 *     <li>Not stored in the synonym file.</li>
// 	 * </ol>
// 	 *
// 	 * @return <code>true</code> if the synonym should be thrown away
// 	 * after use (not stored in the synonym file).
// 	 */
// 	boolean isShortLived();
// 
// 	/**
// 	 * @return The semantic data type of this Synonym, usually something
// 	 *         descriptive as "NAME" or "STREET".
// 	 */
// 	String getType();
// 
// 	/**
// 	 * @return The data which was in the original database for this Synonym
// 	 */
// 	Object getFrom();
// 
// 	/**
// 	 * 
// 	 * @return The data with which the original data in the database will be or
// 	 *         is replaced when the Anonymizer runs.
// 	 */
// 	Object getTo();
// }


import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
import static org.junit.Assert.*;
    }

    @Test
    public void testPostalCodeFlavor1() {
        assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor1());
    }

    @Test
    public void testPostalCodeFlavor2() {
        assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor2());
    }


    private void assertValidPostalCode(String s) {

        if (s.length() > 8) {
            fail("length longer than 8");
        }

        // See https://stackoverflow.com/a/164994
        String regex = "^([Gg][Ii][Rr] ?0[Aa]{2})|" +
                "((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))" +
                " ?[0-9][A-Za-z]{2})$";

        Pattern regexPattern = Pattern.compile(regex);
        assertTrue("Invalid postal code generated: '" + s + "'", regexPattern.matcher(s).matches());
    }

    @Test
    public void testGenerateCorrectSynonym() {
// Path: src/main/java/com/rolfje/anonimatron/synonyms/Synonym.java
// public interface Synonym {
// 
// 	/**
// 	 * Indicates if this Synonym is short-lived or transient, meaning that
//      * it should not be stored in the synonyms file. Transient Synonyms
//      * are not stored, need to be calculated each run time.
// 	 *
// 	 * Transient synonyms are:
// 	 *
// 	 * <ol>
// 	 *     <li>Not stored in memory.</li>
// 	 *     <li>Not stored in the synonym file.</li>
// 	 * </ol>
// 	 *
// 	 * @return <code>true</code> if the synonym should be thrown away
// 	 * after use (not stored in the synonym file).
// 	 */
// 	boolean isShortLived();
// 
// 	/**
// 	 * @return The semantic data type of this Synonym, usually something
// 	 *         descriptive as "NAME" or "STREET".
// 	 */
// 	String getType();
// 
// 	/**
// 	 * @return The data which was in the original database for this Synonym
// 	 */
// 	Object getFrom();
// 
// 	/**
// 	 * 
// 	 * @return The data with which the original data in the database will be or
// 	 *         is replaced when the Anonymizer runs.
// 	 */
// 	Object getTo();
// }


// Path: src/test/java/com/rolfje/anonimatron/anonymizer/UkPostCodeAnonymizerTest.java
import com.rolfje.anonimatron.synonyms.Synonym;
import org.junit.Before;
import org.junit.Test;
import java.util.regex.Pattern;
import static org.junit.Assert.*;

    }

    @Test
    public void testPostalCodeFlavor1() {
        assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor1());
    }

    @Test
    public void testPostalCodeFlavor2() {
        assertValidPostalCode(ukPostCodeAnonymizer.buildZipCodeFlavor2());
    }


    private void assertValidPostalCode(String s) {

        if (s.length() > 8) {
            fail("length longer than 8");
        }

        // See https://stackoverflow.com/a/164994
        String regex = "^([Gg][Ii][Rr] ?0[Aa]{2})|" +
                "((([A-Za-z][0-9]{1,2})|(([A-Za-z][A-Ha-hJ-Yj-y][0-9]{1,2})|(([A-Za-z][0-9][A-Za-z])|([A-Za-z][A-Ha-hJ-Yj-y][0-9]?[A-Za-z]))))" +
                " ?[0-9][A-Za-z]{2})$";

        Pattern regexPattern = Pattern.compile(regex);
        assertTrue("Invalid postal code generated: '" + s + "'", regexPattern.matcher(s).matches());
    }

    @Test
    public void testGenerateCorrectSynonym() {
        Synonym s1 = ukPostCodeAnonymizer.anonymize("x", 10, false);