@Test public void shouldNotifyUserAboutRnrStatusChange() throws Exception { Long rnrId = 1L; String status = "SUBMITTED"; Facility facility = make(a(defaultFacility)); Program program = make(a(defaultProgram)); ProcessingPeriod period = make(a(defaultProcessingPeriod)); User user = new User(); ArrayList<User> userList = new ArrayList<>(); userList.add(user); EmailMessage emailMessage = new EmailMessage(); String actionUrl = baseUrl + "public/pages/logistics/rnr/index.html#/create-rnr/{0}/{2}/{1}?supplyType=fullSupply&page=1"; String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); when(messageService.message("msg.email.notification.subject")).thenReturn("subject"); when(messageService.message(actionUrl, rnrId, program.getId(), facility.getId())).thenReturn("actionUrl"); when(messageService.message("msg.email.notification.body", null, paragraphSeparator, facility.getName(), period.getName(), null, paragraphSeparator, "actionUrl", paragraphSeparator)).thenReturn("body"); emailMessage.setTo(user.getEmail()); emailMessage.setSubject("subject"); emailMessage.setText("body"); service.notifyUsers(userList, rnrId, facility, program, period, status); verify(emailService).processEmailsAsync(asList(emailMessage)); }
public void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status) { String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); List<EmailMessage> mailMessages = new ArrayList<>(); String actionUrl = baseUrl + actionUrlMap.get(status); for (User user : users) { EmailMessage mailMessage = new EmailMessage(); mailMessage.setSubject(messageService.message("msg.email.notification.subject")); mailMessage.setTo(user.getEmail()); mailMessage.setText(messageService.message("msg.email.notification.body", user.getUserName(), paragraphSeparator, facility.getName(), period.getName(), user.getUserName(), paragraphSeparator, messageService.message(actionUrl, rnrId, program.getId(), facility.getId()), paragraphSeparator)); mailMessages.add(mailMessage); } emailService.processEmailsAsync(mailMessages); }
StatusChangeEventService { public void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status) { String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); List<EmailMessage> mailMessages = new ArrayList<>(); String actionUrl = baseUrl + actionUrlMap.get(status); for (User user : users) { EmailMessage mailMessage = new EmailMessage(); mailMessage.setSubject(messageService.message("msg.email.notification.subject")); mailMessage.setTo(user.getEmail()); mailMessage.setText(messageService.message("msg.email.notification.body", user.getUserName(), paragraphSeparator, facility.getName(), period.getName(), user.getUserName(), paragraphSeparator, messageService.message(actionUrl, rnrId, program.getId(), facility.getId()), paragraphSeparator)); mailMessages.add(mailMessage); } emailService.processEmailsAsync(mailMessages); } }
StatusChangeEventService { public void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status) { String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); List<EmailMessage> mailMessages = new ArrayList<>(); String actionUrl = baseUrl + actionUrlMap.get(status); for (User user : users) { EmailMessage mailMessage = new EmailMessage(); mailMessage.setSubject(messageService.message("msg.email.notification.subject")); mailMessage.setTo(user.getEmail()); mailMessage.setText(messageService.message("msg.email.notification.body", user.getUserName(), paragraphSeparator, facility.getName(), period.getName(), user.getUserName(), paragraphSeparator, messageService.message(actionUrl, rnrId, program.getId(), facility.getId()), paragraphSeparator)); mailMessages.add(mailMessage); } emailService.processEmailsAsync(mailMessages); }  }
StatusChangeEventService { public void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status) { String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); List<EmailMessage> mailMessages = new ArrayList<>(); String actionUrl = baseUrl + actionUrlMap.get(status); for (User user : users) { EmailMessage mailMessage = new EmailMessage(); mailMessage.setSubject(messageService.message("msg.email.notification.subject")); mailMessage.setTo(user.getEmail()); mailMessage.setText(messageService.message("msg.email.notification.body", user.getUserName(), paragraphSeparator, facility.getName(), period.getName(), user.getUserName(), paragraphSeparator, messageService.message(actionUrl, rnrId, program.getId(), facility.getId()), paragraphSeparator)); mailMessages.add(mailMessage); } emailService.processEmailsAsync(mailMessages); }  void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status); }
StatusChangeEventService { public void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status) { String newLine = System.getProperty("line.separator"); String paragraphSeparator = newLine.concat(newLine); List<EmailMessage> mailMessages = new ArrayList<>(); String actionUrl = baseUrl + actionUrlMap.get(status); for (User user : users) { EmailMessage mailMessage = new EmailMessage(); mailMessage.setSubject(messageService.message("msg.email.notification.subject")); mailMessage.setTo(user.getEmail()); mailMessage.setText(messageService.message("msg.email.notification.body", user.getUserName(), paragraphSeparator, facility.getName(), period.getName(), user.getUserName(), paragraphSeparator, messageService.message(actionUrl, rnrId, program.getId(), facility.getId()), paragraphSeparator)); mailMessages.add(mailMessage); } emailService.processEmailsAsync(mailMessages); }  void notifyUsers(ArrayList<User> users, Long rnrId, Facility facility, Program program, ProcessingPeriod period, String status);  }