@Test public void test_should_send_email_message_to_topic() { when(sevaRequest.isRequesterEmailAbsent()).thenReturn(false); final String emailAddress = "email@email.com"; final String crn = "crn"; when(sevaRequest.getRequesterEmail()).thenReturn(emailAddress); when(sevaRequest.getCrn()).thenReturn(crn); final String body = "emailBody"; final String subject = "emailSubject"; final String status = "Status"; final String complainantName = "name"; when(sevaRequest.getRequesterName()).thenReturn(complainantName); final String complaintTypeName = "complaintTypeName"; when(sevaRequest.getServiceTypeName()).thenReturn(complaintTypeName); final String locationName = "locationName"; when(sevaRequest.getLocationName()).thenReturn(locationName); final String details = "details"; when(sevaRequest.getDetails()).thenReturn(details); final String formattedDate = "formattedDate"; when(sevaRequest.getFormattedCreatedDate()).thenReturn(formattedDate); when(sevaRequest.getStatusName()).thenReturn(status); final Tenant tenant = new Tenant("tenantName", "ulbGrade"); final List<String> keywords = Collections.emptyList(); final ServiceType serviceType = new ServiceType("serviceType", keywords); when(emailMessageStrategy.matches(any())).thenReturn(true); final HashMap<Object, Object> bodyTemplateValues = new HashMap<>(); final HashMap<Object, Object> subjectTemplateValues = new HashMap<>(); final EmailMessageContext emailMessageContext = EmailMessageContext.builder() .email(emailAddress) .bodyTemplateName("bodyTemplateName") .subjectTemplateName("subjectTemplateName") .bodyTemplateValues(bodyTemplateValues) .subjectTemplateValues(subjectTemplateValues) .build(); when(emailMessageStrategy.getMessageContext(any())).thenReturn(emailMessageContext); when(templateService.loadByName("bodyTemplateName", bodyTemplateValues)).thenReturn(body); when(templateService.loadByName("subjectTemplateName", subjectTemplateValues)).thenReturn(subject); final NotificationContext context = NotificationContext.builder() .sevaRequest(sevaRequest) .serviceType(serviceType) .tenant(tenant) .build(); emailService.send(context); final EmailRequest expectedEmailRequest = EmailRequest.builder() .body(body) .subject(subject) .email(emailAddress) .build(); verify(messageQueueRepository).sendEmail(expectedEmailRequest); }
public void send(NotificationContext context) { final List<EmailRequest> emailRequests = getEmailRequests(context); emailRequests.forEach(emailRequest -> messageQueueRepository.sendEmail(emailRequest)); }
EmailService { public void send(NotificationContext context) { final List<EmailRequest> emailRequests = getEmailRequests(context); emailRequests.forEach(emailRequest -> messageQueueRepository.sendEmail(emailRequest)); } }
EmailService { public void send(NotificationContext context) { final List<EmailRequest> emailRequests = getEmailRequests(context); emailRequests.forEach(emailRequest -> messageQueueRepository.sendEmail(emailRequest)); } EmailService(TemplateService templateService,
                        MessageQueueRepository messageQueueRepository,
                        @Qualifier("emailMessageStrategies") List<EmailMessageStrategy> emailMessageStrategyList); }
EmailService { public void send(NotificationContext context) { final List<EmailRequest> emailRequests = getEmailRequests(context); emailRequests.forEach(emailRequest -> messageQueueRepository.sendEmail(emailRequest)); } EmailService(TemplateService templateService,
                        MessageQueueRepository messageQueueRepository,
                        @Qualifier("emailMessageStrategies") List<EmailMessageStrategy> emailMessageStrategyList); void send(NotificationContext context); }
EmailService { public void send(NotificationContext context) { final List<EmailRequest> emailRequests = getEmailRequests(context); emailRequests.forEach(emailRequest -> messageQueueRepository.sendEmail(emailRequest)); } EmailService(TemplateService templateService,
                        MessageQueueRepository messageQueueRepository,
                        @Qualifier("emailMessageStrategies") List<EmailMessageStrategy> emailMessageStrategyList); void send(NotificationContext context);  }