### Question:
MailService { public void sendAccountActivationMail(JCUser recipient) { try { String urlSuffix = "/user/activate/" + recipient.getUuid(); String url = this.getDeploymentRootUrl() + urlSuffix; Locale locale = recipient.getLanguage().getLocale(); Map<String, Object> model = new HashMap<>(); model.put(NAME, recipient.getUsername()); model.put(LINK, url); model.put(LINK_LABEL, getDeploymentRootUrlWithoutPort() + urlSuffix); model.put(RECIPIENT_LOCALE, locale); this.sendEmail(recipient.getEmail(), messageSource.getMessage("accountActivation.subject", new Object[]{}, locale), model, "accountActivation.vm"); } catch (MailingFailedException e) { LOGGER.error("Failed to sent activation mail for user: " + recipient.getUsername()); } } MailService(JavaMailSender sender,
                       String from,
                       VelocityEngine engine,
                       MessageSource source,
                       JCommuneProperty notificationsEnabledProperty,
                       EscapeTool escapeTool,
                       EntityToDtoConverter converter); void sendPasswordRecoveryMail(JCUser user, String newPassword); void sendUpdatesOnSubscription(JCUser recipient, SubscriptionAwareEntity entity); void sendReceivedPrivateMessageNotification(JCUser recipient, PrivateMessage pm); void sendAccountActivationMail(JCUser recipient); void sendTopicMovedMail(
            JCUser recipient, Topic topic, String curUser, Class<T> subsсriptionTargetClass) ; void sendUserMentionedNotification(JCUser recipient, long postId); void sendRemovingTopicMail(JCUser recipient, Topic topic, String curUser); static final String REMOVE_TOPIC_SUBJECT_TEMPLATE; static final String REMOVE_CODE_REVIEW_SUBJECT_TEMPLATE; static final String REMOVE_TOPIC_MESSAGE_BODY_TEMPLATE; static final String REMOVE_CODE_REVIEW_MESSAGE_BODY_TEMPLATE; }### Answer:
@Test public void testSendActivationMail() throws Exception { enableEmailNotifications(); JCUser user = new JCUser(USERNAME, TO, PASSWORD); service.sendAccountActivationMail(user); this.checkMailCredentials(); assertTrue(this.getMimeMailBody().contains("http: }
@Test public void activationMailShouldNotBeSentIfNotificationsAreDisabled() throws Exception { disableEmailNotifications(); JCUser user = new JCUser(USERNAME, TO, PASSWORD); service.sendAccountActivationMail(user); verify(sender, never()).send(any(MimeMessage.class)); }
@Test public void testSendActivationMailFail() { enableEmailNotifications(); Exception fail = new MailSendException(""); doThrow(fail).when(sender).send(Matchers.<SimpleMailMessage>any()); service.sendAccountActivationMail(new JCUser(USERNAME, TO, PASSWORD)); }