// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
//     @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
//     String getSender();
// 
//     @ApiModelProperty(value = "Subject of the email", required = true)
//     String getSubject();
// 
//     @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
//     String getHtmlTemplate();
// 
//     @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
//     String getTextTemplate();
// 
//     @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value    ", required = true)
//     Map<String, Object> getVariables();
// 
//     @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
//     Collection<String> getRecipients();
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmailImpl.java
// public class TemplatedEmailImpl implements TemplatedEmail {
// 
//     @JsonProperty @NotEmpty private final Collection<String> recipients;
// 
//     @JsonProperty @Email private final String sender;
// 
//     @JsonProperty @NotEmpty private final String subject;
// 
//     @JsonProperty @NotEmpty private final String htmlTemplate;
// 
//     @JsonProperty private final Map<String, Object> variables;
// 
//     @JsonProperty @NotEmpty private final String textTemplate;
// 
//     @JsonCreator
//     public TemplatedEmailImpl(@JsonProperty("recipients") Collection<String> recipients,
//         @JsonProperty("sender") String sender, @JsonProperty("subject") String subject,
//         @JsonProperty("htmlTemplate") String htmlTemplate,
//         @JsonProperty("variables") final Map<String, Object> variables,
//         @JsonProperty("textTemplate") String textTemplate) {
// 
//         this.recipients = recipients;
//         this.sender = sender;
//         this.subject = subject;
//         this.htmlTemplate = htmlTemplate;
//         this.variables = variables;
//         this.textTemplate = textTemplate;
//     }
// 
//     @Override
//     public String getSender() {
//         return sender;
//     }
// 
//     @Override
//     public String getSubject() {
//         return subject;
//     }
// 
//     @Override
//     public String getHtmlTemplate() {
//         return htmlTemplate;
//     }
// 
//     @Override
//     public String getTextTemplate() {
//         return textTemplate;
//     }
// 
//     @Override
//     public Map<String, Object> getVariables() {
//         return variables;
//     }
// 
//     @Override
//     public Collection<String> getRecipients() {
//         return recipients;
//     }
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
// 
//     Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
//         throws InternetAddressParsingException;
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
//     public InternetAddressParsingException(final Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
//     HtmlEmail getHtmlEmail();
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
//     String populateTemplate(String template, Map<String, Object> variables)
//         throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }


import org.apache.commons.mail.HtmlEmail;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmailImpl;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import javax.mail.internet.InternetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Mockito.*;
package uk.gov.homeoffice.emailapi.templatedemailfactory;




public class TemplatedEmailFactoryImplTest {
    public static final String TEMPLATE_CONTENTS = "Template Contents";
    private TemplatePopulator templatePopulator;
    private ArrayList<InternetAddress> internetAddresses;
    private TemplatedEmailFactoryImpl templatedEmailFactory;


    @Before
    public void setupSubject() throws InternetAddressParsingException {
        templatePopulator = mock(TemplatePopulator.class);

        internetAddresses = new ArrayList<>();

        final InternetAddressParser internetAddressParser = mock(InternetAddressParser.class);
        when(internetAddressParser.getInternetAddresses(Matchers.<Collection<String>>any()))
            .thenReturn(internetAddresses);


// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmail.java
// @ApiModel(description = "Enough information to populate and send and email based on a template")
// @JsonDeserialize(as = TemplatedEmailImpl.class)
// @JsonSerialize(as = TemplatedEmailImpl.class)
// public interface TemplatedEmail {
//     @ApiModelProperty(value = "Sender of the email in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
//     String getSender();
// 
//     @ApiModelProperty(value = "Subject of the email", required = true)
//     String getSubject();
// 
//     @ApiModelProperty(value = "If a recipient uses HTML to view their they will see this template", required = true)
//     String getHtmlTemplate();
// 
//     @ApiModelProperty(value = "If a recipient uses TXT to view their they will see this template", required = true)
//     String getTextTemplate();
// 
//     @ApiModelProperty(value = "Variables to pass to both templates with string keys, and any JSON Number, String, Array, Object as the value    ", required = true)
//     Map<String, Object> getVariables();
// 
//     @ApiModelProperty(value = "Array of recipients in an array of strings in format \"example@example.org\" or \"Annie Example <annie@example.com>\"", required = true)
//     Collection<String> getRecipients();
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/entities/TemplatedEmailImpl.java
// public class TemplatedEmailImpl implements TemplatedEmail {
// 
//     @JsonProperty @NotEmpty private final Collection<String> recipients;
// 
//     @JsonProperty @Email private final String sender;
// 
//     @JsonProperty @NotEmpty private final String subject;
// 
//     @JsonProperty @NotEmpty private final String htmlTemplate;
// 
//     @JsonProperty private final Map<String, Object> variables;
// 
//     @JsonProperty @NotEmpty private final String textTemplate;
// 
//     @JsonCreator
//     public TemplatedEmailImpl(@JsonProperty("recipients") Collection<String> recipients,
//         @JsonProperty("sender") String sender, @JsonProperty("subject") String subject,
//         @JsonProperty("htmlTemplate") String htmlTemplate,
//         @JsonProperty("variables") final Map<String, Object> variables,
//         @JsonProperty("textTemplate") String textTemplate) {
// 
//         this.recipients = recipients;
//         this.sender = sender;
//         this.subject = subject;
//         this.htmlTemplate = htmlTemplate;
//         this.variables = variables;
//         this.textTemplate = textTemplate;
//     }
// 
//     @Override
//     public String getSender() {
//         return sender;
//     }
// 
//     @Override
//     public String getSubject() {
//         return subject;
//     }
// 
//     @Override
//     public String getHtmlTemplate() {
//         return htmlTemplate;
//     }
// 
//     @Override
//     public String getTextTemplate() {
//         return textTemplate;
//     }
// 
//     @Override
//     public Map<String, Object> getVariables() {
//         return variables;
//     }
// 
//     @Override
//     public Collection<String> getRecipients() {
//         return recipients;
//     }
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParser.java
// public interface InternetAddressParser {
// 
//     Collection<InternetAddress> getInternetAddresses(Collection<String> unparsedRecipients)
//         throws InternetAddressParsingException;
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/addressparsing/InternetAddressParsingException.java
// public class InternetAddressParsingException extends Exception {
//     public InternetAddressParsingException(final Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/serverconfig/HtmlEmailFactory.java
// public interface HtmlEmailFactory {
//     HtmlEmail getHtmlEmail();
// }
// 
// Path: src/main/java/uk/gov/homeoffice/emailapi/templatedemailfactory/templating/TemplatePopulator.java
// public interface TemplatePopulator {
//     String populateTemplate(String template, Map<String, Object> variables)
//         throws TemplatePopulatorIOException, TemplatePopulatorParsingException;
// }


// Path: src/test/java/uk/gov/homeoffice/emailapi/templatedemailfactory/TemplatedEmailFactoryImplTest.java
import org.apache.commons.mail.HtmlEmail;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Matchers;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmail;
import uk.gov.homeoffice.emailapi.entities.TemplatedEmailImpl;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParser;
import uk.gov.homeoffice.emailapi.templatedemailfactory.addressparsing.InternetAddressParsingException;
import uk.gov.homeoffice.emailapi.templatedemailfactory.serverconfig.HtmlEmailFactory;
import uk.gov.homeoffice.emailapi.templatedemailfactory.templating.TemplatePopulator;
import javax.mail.internet.InternetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Mockito.*;

package uk.gov.homeoffice.emailapi.templatedemailfactory;




public class TemplatedEmailFactoryImplTest {
    public static final String TEMPLATE_CONTENTS = "Template Contents";
    private TemplatePopulator templatePopulator;
    private ArrayList<InternetAddress> internetAddresses;
    private TemplatedEmailFactoryImpl templatedEmailFactory;


    @Before
    public void setupSubject() throws InternetAddressParsingException {
        templatePopulator = mock(TemplatePopulator.class);

        internetAddresses = new ArrayList<>();

        final InternetAddressParser internetAddressParser = mock(InternetAddressParser.class);
        when(internetAddressParser.getInternetAddresses(Matchers.<Collection<String>>any()))
            .thenReturn(internetAddresses);


        final HtmlEmailFactory htmlEmailFactory = mock(HtmlEmailFactory.class);