SubscriptionMailer { @Subscribe public void pageChanged(PageChangedEvent event) { final String projectName = event.getProjectName(); final String branchName = event.getBranchName(); final String path = event.getPath(); Runnable runnable = new Runnable() { @Override public void run() { log.info("page changed, sending notifications: {}/{}/{}", projectName, branchName, Util.toUrlPagePath(path)); try { sendNotifications(projectName, branchName, path); } catch (IOException e) { log.error("error sending notifications", e); } catch (RuntimeException e) { log.error("error sending notifications", e); } } }; taskExecutor.submit(runnable); }  @Subscribe void pageChanged(PageChangedEvent event);  }
@Test public void pageChanged() throws IOException, MessagingException { mailer.pageChanged(new PageChangedEvent(PROJECT, BRANCH, PAGE)); verify(message).setFrom(new InternetAddress(SENDER_EMAIL, SENDER_NAME, Charsets.UTF_8.name())); verify(message).setRecipient(RecipientType.TO, new InternetAddress(SUBSCRIBER_EMAIL)); verify(message).setSubject(SUBJECT_PREFIX + " " + MAIL_SUBJECT, Charsets.UTF_8.name()); verify(message).setText(MAIL_TEXT, Charsets.UTF_8.name()); verify(sender).send(message); }