@Test public void test_should_send_email_to_email_topic() { final String emailAddress = "email@email.com"; final SendResult<String, Object> sendResult = new SendResult<>(null, null); final String body = "body"; final String subject = "subject"; final EmailMessage expectedEmailMessage = EmailMessage.builder() .email(emailAddress) .subject(subject) .body(body) .sender("") .build(); when(kafkaTemplate.send(EMAIL_TOPIC, expectedEmailMessage)).thenReturn(sendResult); final EmailRequest emailRequest = new EmailRequest(subject, body, emailAddress); messageQueueRepository.sendEmail(emailRequest); verify(kafkaTemplate).send(EMAIL_TOPIC, expectedEmailMessage); }
public void sendEmail(EmailRequest emailRequest) { final EmailMessage emailMessage = EmailMessage.builder() .body(emailRequest.getBody()) .subject(emailRequest.getSubject()) .sender(EMPTY) .email(emailRequest.getEmail()) .build(); sendMessage(emailTopic, emailMessage); }
MessageQueueRepository { public void sendEmail(EmailRequest emailRequest) { final EmailMessage emailMessage = EmailMessage.builder() .body(emailRequest.getBody()) .subject(emailRequest.getSubject()) .sender(EMPTY) .email(emailRequest.getEmail()) .build(); sendMessage(emailTopic, emailMessage); } }
MessageQueueRepository { public void sendEmail(EmailRequest emailRequest) { final EmailMessage emailMessage = EmailMessage.builder() .body(emailRequest.getBody()) .subject(emailRequest.getSubject()) .sender(EMPTY) .email(emailRequest.getEmail()) .build(); sendMessage(emailTopic, emailMessage); } MessageQueueRepository(LogAwareKafkaTemplate<String, Object> kafkaTemplate,
                                  @Value("${sms.topic}") String smsTopic,
                                  @Value("${email.topic}") String emailTopic); }
MessageQueueRepository { public void sendEmail(EmailRequest emailRequest) { final EmailMessage emailMessage = EmailMessage.builder() .body(emailRequest.getBody()) .subject(emailRequest.getSubject()) .sender(EMPTY) .email(emailRequest.getEmail()) .build(); sendMessage(emailTopic, emailMessage); } MessageQueueRepository(LogAwareKafkaTemplate<String, Object> kafkaTemplate,
                                  @Value("${sms.topic}") String smsTopic,
                                  @Value("${email.topic}") String emailTopic); void sendSMS(SMSRequest smsRequest); void sendEmail(EmailRequest emailRequest); }
MessageQueueRepository { public void sendEmail(EmailRequest emailRequest) { final EmailMessage emailMessage = EmailMessage.builder() .body(emailRequest.getBody()) .subject(emailRequest.getSubject()) .sender(EMPTY) .email(emailRequest.getEmail()) .build(); sendMessage(emailTopic, emailMessage); } MessageQueueRepository(LogAwareKafkaTemplate<String, Object> kafkaTemplate,
                                  @Value("${sms.topic}") String smsTopic,
                                  @Value("${email.topic}") String emailTopic); void sendSMS(SMSRequest smsRequest); void sendEmail(EmailRequest emailRequest);  }