@Test public void sendAddedNewPlacesReportEmailTest() { CategoryDto testCategory = CategoryDto.builder().name("CategoryName").build(); PlaceNotificationDto testPlace1 = PlaceNotificationDto.builder().name("PlaceName1").category(testCategory).build(); PlaceNotificationDto testPlace2 = PlaceNotificationDto.builder().name("PlaceName2").category(testCategory).build(); Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlacesTest = new HashMap<>(); categoriesWithPlacesTest.put(testCategory, Arrays.asList(testPlace1, testPlace2)); service.sendAddedNewPlacesReportEmail( Collections.singletonList(placeAuthorDto), categoriesWithPlacesTest, "DAILY"); verify(javaMailSender).createMimeMessage(); }
@Override public void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers, Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces, String notification) { log.info(LogMessage.IN_SEND_ADDED_NEW_PLACES_REPORT_EMAIL, null, null, notification); Map<String, Object> model = new HashMap<>(); model.put(EmailConstants.CLIENT_LINK, clientLink); model.put(EmailConstants.RESULT, categoriesWithPlaces); model.put(EmailConstants.REPORT_TYPE, notification); for (PlaceAuthorDto user : subscribers) { model.put(EmailConstants.USER_NAME, user.getName()); String template = createEmailTemplate(model, EmailConstants.NEW_PLACES_REPORT_EMAIL_PAGE); sendEmail(user.getEmail(), EmailConstants.NEW_PLACES, template); } }
EmailServiceImpl implements EmailService { @Override public void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers, Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces, String notification) { log.info(LogMessage.IN_SEND_ADDED_NEW_PLACES_REPORT_EMAIL, null, null, notification); Map<String, Object> model = new HashMap<>(); model.put(EmailConstants.CLIENT_LINK, clientLink); model.put(EmailConstants.RESULT, categoriesWithPlaces); model.put(EmailConstants.REPORT_TYPE, notification); for (PlaceAuthorDto user : subscribers) { model.put(EmailConstants.USER_NAME, user.getName()); String template = createEmailTemplate(model, EmailConstants.NEW_PLACES_REPORT_EMAIL_PAGE); sendEmail(user.getEmail(), EmailConstants.NEW_PLACES, template); } } }
EmailServiceImpl implements EmailService { @Override public void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers, Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces, String notification) { log.info(LogMessage.IN_SEND_ADDED_NEW_PLACES_REPORT_EMAIL, null, null, notification); Map<String, Object> model = new HashMap<>(); model.put(EmailConstants.CLIENT_LINK, clientLink); model.put(EmailConstants.RESULT, categoriesWithPlaces); model.put(EmailConstants.REPORT_TYPE, notification); for (PlaceAuthorDto user : subscribers) { model.put(EmailConstants.USER_NAME, user.getName()); String template = createEmailTemplate(model, EmailConstants.NEW_PLACES_REPORT_EMAIL_PAGE); sendEmail(user.getEmail(), EmailConstants.NEW_PLACES, template); } } @Autowired  EmailServiceImpl(JavaMailSender javaMailSender,
                            ITemplateEngine templateEngine,
                            @Qualifier("sendEmailExecutor") Executor executor,
                            @Value("${client.address}") String clientLink,
                            @Value("${econews.address}") String ecoNewsLink,
                            @Value("${address}") String serverLink,
                            @Value("${sender.email.address}") String senderEmailAddress); }
EmailServiceImpl implements EmailService { @Override public void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers, Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces, String notification) { log.info(LogMessage.IN_SEND_ADDED_NEW_PLACES_REPORT_EMAIL, null, null, notification); Map<String, Object> model = new HashMap<>(); model.put(EmailConstants.CLIENT_LINK, clientLink); model.put(EmailConstants.RESULT, categoriesWithPlaces); model.put(EmailConstants.REPORT_TYPE, notification); for (PlaceAuthorDto user : subscribers) { model.put(EmailConstants.USER_NAME, user.getName()); String template = createEmailTemplate(model, EmailConstants.NEW_PLACES_REPORT_EMAIL_PAGE); sendEmail(user.getEmail(), EmailConstants.NEW_PLACES, template); } } @Autowired  EmailServiceImpl(JavaMailSender javaMailSender,
                            ITemplateEngine templateEngine,
                            @Qualifier("sendEmailExecutor") Executor executor,
                            @Value("${client.address}") String clientLink,
                            @Value("${econews.address}") String ecoNewsLink,
                            @Value("${address}") String serverLink,
                            @Value("${sender.email.address}") String senderEmailAddress); @Override void sendChangePlaceStatusEmail(String authorName, String placeName,
                                           String placeStatus, String authorEmail); @Override void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers,
                                              Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces,
                                              String notification); @Override void sendNewNewsForSubscriber(List<NewsSubscriberResponseDto> subscribers,
                                         AddEcoNewsDtoResponse newsDto); @Override void sendVerificationEmail(Long id, String name, String email, String token); @Override void sendRestoreEmail(Long userId, String userName, String userEmail, String token); @Override void sendHabitNotification(String name, String email); }
EmailServiceImpl implements EmailService { @Override public void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers, Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces, String notification) { log.info(LogMessage.IN_SEND_ADDED_NEW_PLACES_REPORT_EMAIL, null, null, notification); Map<String, Object> model = new HashMap<>(); model.put(EmailConstants.CLIENT_LINK, clientLink); model.put(EmailConstants.RESULT, categoriesWithPlaces); model.put(EmailConstants.REPORT_TYPE, notification); for (PlaceAuthorDto user : subscribers) { model.put(EmailConstants.USER_NAME, user.getName()); String template = createEmailTemplate(model, EmailConstants.NEW_PLACES_REPORT_EMAIL_PAGE); sendEmail(user.getEmail(), EmailConstants.NEW_PLACES, template); } } @Autowired  EmailServiceImpl(JavaMailSender javaMailSender,
                            ITemplateEngine templateEngine,
                            @Qualifier("sendEmailExecutor") Executor executor,
                            @Value("${client.address}") String clientLink,
                            @Value("${econews.address}") String ecoNewsLink,
                            @Value("${address}") String serverLink,
                            @Value("${sender.email.address}") String senderEmailAddress); @Override void sendChangePlaceStatusEmail(String authorName, String placeName,
                                           String placeStatus, String authorEmail); @Override void sendAddedNewPlacesReportEmail(List<PlaceAuthorDto> subscribers,
                                              Map<CategoryDto, List<PlaceNotificationDto>> categoriesWithPlaces,
                                              String notification); @Override void sendNewNewsForSubscriber(List<NewsSubscriberResponseDto> subscribers,
                                         AddEcoNewsDtoResponse newsDto); @Override void sendVerificationEmail(Long id, String name, String email, String token); @Override void sendRestoreEmail(Long userId, String userName, String userEmail, String token); @Override void sendHabitNotification(String name, String email);  }