### Question:
EmailServiceImpl implements EmailService { @Override @CatAnnotation public void send(NotificationType type, Recipient recipient, String attachment) throws MessagingException, IOException { final String subject = env.getProperty(type.getSubject()); final String text = MessageFormat.format(env.getProperty(type.getText()), recipient.getAccountName()); MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); helper.setTo(recipient.getEmail()); helper.setSubject(subject); helper.setText(text); if (StringUtils.hasLength(attachment)) { helper.addAttachment(env.getProperty(type.getAttachment()), new ByteArrayResource(attachment.getBytes())); } mailSender.send(message); log.info("{} email notification has been send to {}", type, recipient.getEmail()); }  @Override @CatAnnotation void send(NotificationType type, Recipient recipient, String attachment);  }### Answer:
@Test public void shouldSendBackupEmail() throws MessagingException, IOException { final String subject = "subject"; final String text = "text"; final String attachment = "attachment.json"; Recipient recipient = new Recipient(); recipient.setAccountName("test"); recipient.setEmail("test@test.com"); when(env.getProperty(NotificationType.BACKUP.getSubject())).thenReturn(subject); when(env.getProperty(NotificationType.BACKUP.getText())).thenReturn(text); when(env.getProperty(NotificationType.BACKUP.getAttachment())).thenReturn(attachment); emailService.send(NotificationType.BACKUP, recipient, "{\"name\":\"test\""); verify(mailSender).send(captor.capture()); MimeMessage message = captor.getValue(); assertEquals(subject, message.getSubject()); }
@Test public void shouldSendRemindEmail() throws MessagingException, IOException { final String subject = "subject"; final String text = "text"; Recipient recipient = new Recipient(); recipient.setAccountName("test"); recipient.setEmail("test@test.com"); when(env.getProperty(NotificationType.REMIND.getSubject())).thenReturn(subject); when(env.getProperty(NotificationType.REMIND.getText())).thenReturn(text); emailService.send(NotificationType.REMIND, recipient, null); verify(mailSender).send(captor.capture()); MimeMessage message = captor.getValue(); assertEquals(subject, message.getSubject()); }