@Test public void testSendEmail() throws MessagingException { ContactDto contactDto = mock(ContactDto.class); String msg = "I am interested to learn how to sign up for Consent 2 Share."; when(contactDto.getFirstName()).thenReturn("firstname"); when(contactDto.getLastName()).thenReturn("laststname"); when(contactDto.getEmail()).thenReturn("firstname@gmail.com"); when(contactDto.getEmailConfirmation()).thenReturn("firstname@gmail.com"); when(contactDto.getTelephoneNumber()).thenReturn("1111111111"); when(contactDto.getMessageCode()).thenReturn("1"); contactService.sendEmail(contactDto); verify(emailSender, times(1)).sendContactMessage(EmailType.REQUEST_MORE_INFORMATION,contactDto.getFirstName(),contactDto.getLastName(), contactDto.getEmail(),contactDto.getTelephoneNumber(),msg); verify(emailSender, times(1)).sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION,"", "", contactDto.getEmail(), "", ""); }
@Override public void sendEmail(ContactDto contactDto) { try { String message = ""; if(contactDto.getMessageCode().equals("1")){ message = "I am interested to learn how to sign up for Consent 2 Share."; }else if(contactDto.getMessageCode().equals("2")){ message = "I am interested in information to learn more about managing who can see my patient records"; } emailSender.sendContactMessage(EmailType.REQUEST_MORE_INFORMATION, contactDto.getFirstName(), contactDto.getLastName(),contactDto.getEmail(), contactDto.getTelephoneNumber(), message); emailSender.sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION, "", "", contactDto.getEmail(), "", ""); } catch (MessagingException e) { logger.error(e.getMessage(), e); } }
ContactServiceImpl implements ContactService { @Override public void sendEmail(ContactDto contactDto) { try { String message = ""; if(contactDto.getMessageCode().equals("1")){ message = "I am interested to learn how to sign up for Consent 2 Share."; }else if(contactDto.getMessageCode().equals("2")){ message = "I am interested in information to learn more about managing who can see my patient records"; } emailSender.sendContactMessage(EmailType.REQUEST_MORE_INFORMATION, contactDto.getFirstName(), contactDto.getLastName(),contactDto.getEmail(), contactDto.getTelephoneNumber(), message); emailSender.sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION, "", "", contactDto.getEmail(), "", ""); } catch (MessagingException e) { logger.error(e.getMessage(), e); } } }
ContactServiceImpl implements ContactService { @Override public void sendEmail(ContactDto contactDto) { try { String message = ""; if(contactDto.getMessageCode().equals("1")){ message = "I am interested to learn how to sign up for Consent 2 Share."; }else if(contactDto.getMessageCode().equals("2")){ message = "I am interested in information to learn more about managing who can see my patient records"; } emailSender.sendContactMessage(EmailType.REQUEST_MORE_INFORMATION, contactDto.getFirstName(), contactDto.getLastName(),contactDto.getEmail(), contactDto.getTelephoneNumber(), message); emailSender.sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION, "", "", contactDto.getEmail(), "", ""); } catch (MessagingException e) { logger.error(e.getMessage(), e); } } ContactServiceImpl(EmailSender emailSender); }
ContactServiceImpl implements ContactService { @Override public void sendEmail(ContactDto contactDto) { try { String message = ""; if(contactDto.getMessageCode().equals("1")){ message = "I am interested to learn how to sign up for Consent 2 Share."; }else if(contactDto.getMessageCode().equals("2")){ message = "I am interested in information to learn more about managing who can see my patient records"; } emailSender.sendContactMessage(EmailType.REQUEST_MORE_INFORMATION, contactDto.getFirstName(), contactDto.getLastName(),contactDto.getEmail(), contactDto.getTelephoneNumber(), message); emailSender.sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION, "", "", contactDto.getEmail(), "", ""); } catch (MessagingException e) { logger.error(e.getMessage(), e); } } ContactServiceImpl(EmailSender emailSender); @Override void sendEmail(ContactDto contactDto); }
ContactServiceImpl implements ContactService { @Override public void sendEmail(ContactDto contactDto) { try { String message = ""; if(contactDto.getMessageCode().equals("1")){ message = "I am interested to learn how to sign up for Consent 2 Share."; }else if(contactDto.getMessageCode().equals("2")){ message = "I am interested in information to learn more about managing who can see my patient records"; } emailSender.sendContactMessage(EmailType.REQUEST_MORE_INFORMATION, contactDto.getFirstName(), contactDto.getLastName(),contactDto.getEmail(), contactDto.getTelephoneNumber(), message); emailSender.sendContactMessage(EmailType.CONFIRM_REQUEST_MORE_INFORMATION, "", "", contactDto.getEmail(), "", ""); } catch (MessagingException e) { logger.error(e.getMessage(), e); } } ContactServiceImpl(EmailSender emailSender); @Override void sendEmail(ContactDto contactDto);  }