### Question:
MailService { void sendTopicCreationMail(JCUser subscriber, Topic topic) { try { String urlSuffix = getTopicUrlSuffix(topic); String url = this.getDeploymentRootUrl() + urlSuffix; Locale locale = subscriber.getLanguage().getLocale(); Map<String, Object> model = new HashMap<>(); model.put(LINK, url); model.put(LINK_UNSUBSCRIBE, this.getDeploymentRootUrl() + topic.getBranch().getUnsubscribeLinkForSubscribersOf(Branch.class)); model.put(LINK_LABEL, getDeploymentRootUrlWithoutPort() + urlSuffix); sendEmailOnForumUpdates(subscriber, model, locale, topic.getBranch(), "subscriptionNotification.subject", "branchSubscriptionNotification.vm"); } catch (MailingFailedException e) { LOGGER.error("Failed to sent mail about creation topic for user: " + subscriber.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 testSendTopicCreationMail() throws Exception { enableEmailNotifications(); branch.addTopic(topic); service.sendTopicCreationMail(user, topic); this.checkMailCredentials(); String subjectTemplate = messageSource.getMessage("subscriptionNotification.subject", new Object[]{}, user.getLanguage().getLocale()); String bodyTemplate = messageSource.getMessage("branchSubscriptionNotification.content", new Object[]{}, user.getLanguage().getLocale()); assertEquals(this.getMimeMailSubject(), subjectTemplate + ": " + branch.getName()); assertTrue(this.getMimeMailBody().contains(bodyTemplate)); assertTrue(this.getMimeMailBody().contains("http: assertTrue(this.getMimeMailBody().contains("http: + "/unsubscribe")); }
@Test public void topicCreationMailShouldNotSentWhenForumNotificationsAreDisabled() throws Exception { disableEmailNotifications(); branch.addTopic(topic); service.sendTopicCreationMail(user, topic); verify(sender, never()).send(any(MimeMessage.class)); }