// Path: src/main/java/com/maxmind/minfraud/request/Email.java
// public static final class Builder {
//     private final boolean enableValidation;
//     private String address;
//     private boolean hashAddress;
//     private String domain;
// 
//     /**
//      * The constructor for the builder.
//      * <p>
//      * By default, validation will be enabled.
//      */
//     public Builder() {
//         enableValidation = true;
//     }
// 
//     /**
//      * The constructor for the builder.
//      *
//      * @param enableValidation Whether validation should be enabled.
//      */
//     public Builder(boolean enableValidation) {
//         this.enableValidation = enableValidation;
//     }
// 
//     /**
//      * Set the email address and domain fields for the request. If
//      * you set the email address from this method, you do <em>not</em>
//      * need to set the domain separately. The domain will be set to
//      * the domain of the email address and the address field will be
//      * set to the email address passed.
//      * <p>
//      * The email address will be sent in plain text unless you also call
//      * {@link #hashAddress()} to instead send it as an MD5 hash.
//      *
//      * @param address The valid email address used in the transaction.
//      * @return The builder object.
//      * @throws IllegalArgumentException when address is not a valid email
//      *                                  address.
//      */
//     public Email.Builder address(String address) {
//         if (enableValidation && !EmailValidator.getInstance().isValid(address)) {
//             throw new IllegalArgumentException("The email address " + address + " is not valid.");
//         }
// 
//         if (this.domain == null) {
//             int domainIndex = address.lastIndexOf('@') + 1;
//             if (domainIndex > 0 && domainIndex < address.length()) {
//                 this.domain = address.substring(domainIndex);
//             }
//         }
//         this.address = address;
//         return this;
//     }
// 
//     /**
//      * Send the email address as its MD5 hash.
//      * <p>
//      * By default, the email address set by {@link #address(String)} will be
//      * sent in plain text. Enable sending it as an MD5 hash instead by
//      * calling this method.
//      *
//      * @return The builder object.
//      */
//     public Email.Builder hashAddress() {
//         this.hashAddress = true;
//         return this;
//     }
// 
//     /**
//      * @param domain The domain of the email address. This only needs
//      *               to be set if the email address is not set.
//      * @return The builder object.
//      * @throws IllegalArgumentException when domain is not a valid domain.
//      */
//     public Email.Builder domain(String domain) {
//         if (enableValidation && !DomainValidator.getInstance().isValid(domain)) {
//             throw new IllegalArgumentException("The email domain " + domain + " is not valid.");
//         }
//         this.domain = domain;
//         return this;
//     }
// 
//     /**
//      * @return An instance of {@code Email} created from the
//      * fields set on this builder.
//      */
//     public Email build() {
//         return new Email(this);
//     }
// }


import com.maxmind.minfraud.request.Email.Builder;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
        Email email = new Builder().address("test@test.org").hashAddress().hashAddress().build();
        assertEquals("MD5 generated from email", "476869598e748d958e819c180af31982", email.getAddress());
        assertEquals("domain set from email", "test.org", email.getDomain());
    }

    @Test
    public void testHashAddressWithoutAddress() {
        Email email = new Builder().domain("test.org").hashAddress().build();
        assertEquals("domain is set", "test.org", email.getDomain());
    }

    @Test
    public void testMd5GetsLowercased() {
        Email email = new Builder().address("TEST@TEST.org").hashAddress().build();
        assertEquals("MD5 generated from lowercased email", "476869598e748d958e819c180af31982", email.getAddress());
    }

    @Test
    public void testGetAddressWithoutSettingIt() {
        Email email = new Builder().domain("test.org").hashAddress().build();
        assertNull("null address if none set", email.getAddress());

        Email email2 = new Builder().domain("test.org").hashAddress().build();
        assertNull("null address if none set", email2.getAddress());
    }

    @Test
    public void testNormalizing() {
        Email e;

// Path: src/main/java/com/maxmind/minfraud/request/Email.java
// public static final class Builder {
//     private final boolean enableValidation;
//     private String address;
//     private boolean hashAddress;
//     private String domain;
// 
//     /**
//      * The constructor for the builder.
//      * <p>
//      * By default, validation will be enabled.
//      */
//     public Builder() {
//         enableValidation = true;
//     }
// 
//     /**
//      * The constructor for the builder.
//      *
//      * @param enableValidation Whether validation should be enabled.
//      */
//     public Builder(boolean enableValidation) {
//         this.enableValidation = enableValidation;
//     }
// 
//     /**
//      * Set the email address and domain fields for the request. If
//      * you set the email address from this method, you do <em>not</em>
//      * need to set the domain separately. The domain will be set to
//      * the domain of the email address and the address field will be
//      * set to the email address passed.
//      * <p>
//      * The email address will be sent in plain text unless you also call
//      * {@link #hashAddress()} to instead send it as an MD5 hash.
//      *
//      * @param address The valid email address used in the transaction.
//      * @return The builder object.
//      * @throws IllegalArgumentException when address is not a valid email
//      *                                  address.
//      */
//     public Email.Builder address(String address) {
//         if (enableValidation && !EmailValidator.getInstance().isValid(address)) {
//             throw new IllegalArgumentException("The email address " + address + " is not valid.");
//         }
// 
//         if (this.domain == null) {
//             int domainIndex = address.lastIndexOf('@') + 1;
//             if (domainIndex > 0 && domainIndex < address.length()) {
//                 this.domain = address.substring(domainIndex);
//             }
//         }
//         this.address = address;
//         return this;
//     }
// 
//     /**
//      * Send the email address as its MD5 hash.
//      * <p>
//      * By default, the email address set by {@link #address(String)} will be
//      * sent in plain text. Enable sending it as an MD5 hash instead by
//      * calling this method.
//      *
//      * @return The builder object.
//      */
//     public Email.Builder hashAddress() {
//         this.hashAddress = true;
//         return this;
//     }
// 
//     /**
//      * @param domain The domain of the email address. This only needs
//      *               to be set if the email address is not set.
//      * @return The builder object.
//      * @throws IllegalArgumentException when domain is not a valid domain.
//      */
//     public Email.Builder domain(String domain) {
//         if (enableValidation && !DomainValidator.getInstance().isValid(domain)) {
//             throw new IllegalArgumentException("The email domain " + domain + " is not valid.");
//         }
//         this.domain = domain;
//         return this;
//     }
// 
//     /**
//      * @return An instance of {@code Email} created from the
//      * fields set on this builder.
//      */
//     public Email build() {
//         return new Email(this);
//     }
// }


// Path: src/test/java/com/maxmind/minfraud/request/EmailTest.java
import com.maxmind.minfraud.request.Email.Builder;
import org.junit.Test;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

        Email email = new Builder().address("test@test.org").hashAddress().hashAddress().build();
        assertEquals("MD5 generated from email", "476869598e748d958e819c180af31982", email.getAddress());
        assertEquals("domain set from email", "test.org", email.getDomain());
    }

    @Test
    public void testHashAddressWithoutAddress() {
        Email email = new Builder().domain("test.org").hashAddress().build();
        assertEquals("domain is set", "test.org", email.getDomain());
    }

    @Test
    public void testMd5GetsLowercased() {
        Email email = new Builder().address("TEST@TEST.org").hashAddress().build();
        assertEquals("MD5 generated from lowercased email", "476869598e748d958e819c180af31982", email.getAddress());
    }

    @Test
    public void testGetAddressWithoutSettingIt() {
        Email email = new Builder().domain("test.org").hashAddress().build();
        assertNull("null address if none set", email.getAddress());

        Email email2 = new Builder().domain("test.org").hashAddress().build();
        assertNull("null address if none set", email2.getAddress());
    }

    @Test
    public void testNormalizing() {
        Email e;

        e = new Builder().address("test@maxmind.com").hashAddress().build();