use of br.com.caelum.vraptor.simplemail.template.TemplateMail in project mamute by caelum.
the class NewQuestionMailerTest method setup.
@Before
public void setup() {
this.mailer = mock(AsyncMailer.class);
TemplateMailer templates = mock(TemplateMailer.class);
BundleFormatter bundle = mock(BundleFormatter.class);
Linker linker = mock(Linker.class);
QuestionController questionController = mock(QuestionController.class);
this.request = mock(HttpServletRequest.class);
TemplateMail mail = mock(TemplateMail.class);
this.questionMailer = new NewQuestionMailer(mailer, templates, bundle, linker, "logo");
when(request.getRemoteAddr()).thenReturn("127.0.0.1");
when(linker.linkTo(QuestionController.class)).thenReturn(questionController);
when(templates.template(anyString())).thenReturn(mail);
when(mail.with(anyString(), any())).thenReturn(mail);
}
use of br.com.caelum.vraptor.simplemail.template.TemplateMail in project mamute by caelum.
the class NewQuestionMailer method send.
public void send(List<User> subscribed, Question question) {
linker.linkTo(QuestionController.class).showQuestion(question, question.getSluggedTitle());
String questionLink = linker.get();
TemplateMail template = templates.template("new_question_notification").with("question", question).with("bundle", bundle).with("questionLink", questionLink).with("logoUrl", emailLogo);
for (User user : subscribed) {
boolean notSameAuthor = !user.equals(question.getAuthor());
if (notSameAuthor) {
Email email = template.to(user.getName(), user.getEmail());
mailer.asyncSend(email);
}
}
}
Aggregations