@Test public void test_should_send_sms_with_generated_message_from_template() { when(sevaRequest.getServiceTypeName()).thenReturn("name"); when(sevaRequest.getCrn()).thenReturn("crn"); when(sevaRequest.getStatusName()).thenReturn("Registerd"); when(sevaRequest.getMobileNumber()).thenReturn("mobileNumber"); final Map<Object, Object> requestMap = ImmutableMap.of( "name", "name", "number", "crn", "statusLowerCase","registerd" ); final List<String> keywords = Collections.singletonList("COMPLAINT"); final ServiceType serviceType = new ServiceType("serviceName", keywords); when(smsMessageStrategy1.matches(any())).thenReturn(true); when(smsMessageStrategy2.matches(any())).thenReturn(true); final SMSMessageContext messageContext1 = new SMSMessageContext("sms_en1", requestMap, "mobileNumber"); final SMSMessageContext messageContext2 = new SMSMessageContext("sms_en2", requestMap, "mobileNumber"); final Tenant tenant = new Tenant("name", "grade"); when(smsMessageStrategy1.getMessageContext(any())).thenReturn(messageContext1); when(smsMessageStrategy2.getMessageContext(any())).thenReturn(messageContext2); when(templateService.loadByName("sms_en1", requestMap)).thenReturn("smsMessage1"); when(templateService.loadByName("sms_en2", requestMap)).thenReturn("smsMessage2"); final NotificationContext context = NotificationContext.builder() .sevaRequest(sevaRequest) .serviceType(serviceType) .tenant(tenant) .build(); smsService.send(context); verify(messageQueueRepository).sendSMS(new SMSRequest("smsMessage1", "mobileNumber")); verify(messageQueueRepository).sendSMS(new SMSRequest("smsMessage2", "mobileNumber")); }
public void send(NotificationContext context) { final List<SMSRequest> smsRequests = getSMSRequests(context); smsRequests.forEach(smsRequest -> messageQueueRepository.sendSMS(smsRequest)); }
SMSService { public void send(NotificationContext context) { final List<SMSRequest> smsRequests = getSMSRequests(context); smsRequests.forEach(smsRequest -> messageQueueRepository.sendSMS(smsRequest)); } }
SMSService { public void send(NotificationContext context) { final List<SMSRequest> smsRequests = getSMSRequests(context); smsRequests.forEach(smsRequest -> messageQueueRepository.sendSMS(smsRequest)); } SMSService(TemplateService templateService,
                      MessageQueueRepository messageQueueRepository,
                      @Qualifier("smsMessageStrategies") List<SMSMessageStrategy> messageStrategyList); }
SMSService { public void send(NotificationContext context) { final List<SMSRequest> smsRequests = getSMSRequests(context); smsRequests.forEach(smsRequest -> messageQueueRepository.sendSMS(smsRequest)); } SMSService(TemplateService templateService,
                      MessageQueueRepository messageQueueRepository,
                      @Qualifier("smsMessageStrategies") List<SMSMessageStrategy> messageStrategyList); void send(NotificationContext context); }
SMSService { public void send(NotificationContext context) { final List<SMSRequest> smsRequests = getSMSRequests(context); smsRequests.forEach(smsRequest -> messageQueueRepository.sendSMS(smsRequest)); } SMSService(TemplateService templateService,
                      MessageQueueRepository messageQueueRepository,
                      @Qualifier("smsMessageStrategies") List<SMSMessageStrategy> messageStrategyList); void send(NotificationContext context);  }