### Question:
VertxMailClient implements MailClient { @Override public Mono<MailResult> send(MailMessage message) { return mailMessageConverter .toVertxMailMessage(message) .flatMap(vertxMessage -> delegate.sendMail(vertxMessage) .convert() .with(UniReactorConverters.toMono())) .map(mailResultConverter::fromVertxMailResult); } VertxMailClient(io.vertx.mutiny.ext.mail.MailClient delegate, MailMessageConverter mailMessageConverter,
        MailResultConverter mailResultConverter); @Override Mono<MailResult> send(MailMessage message);  }### Answer:
@Test public void shouldSendMessageWithBasicFields() { MultiValueMap<String, String> headers = new LinkedMultiValueMap<>(); headers.add("test", "example1"); headers.add("test", "example2"); MailMessage message = new SimpleMailMessage() .setFrom("from@example.com") .addTo("to@example.com") .addCc("cc@example.com") .addBcc("bcc@example.com") .setBounceAddress("bounce@example.com") .setSubject("Test subject") .setText("Test text") .setHtml("Test html") .setHeaders(headers); MailResult result = mailClient.send(message) .blockOptional() .orElseThrow(RuntimeException::new); assertThat(result.getMessageId()).isEqualTo("1"); assertThat(result.getRecipients()).containsOnly("to@example.com", "cc@example.com", "bcc@example.com"); ArgumentCaptor<io.vertx.ext.mail.MailMessage> vertxMessageCaptor = ArgumentCaptor.forClass(io.vertx.ext.mail.MailMessage.class); verify(mockMutinyMailClient).sendMail(vertxMessageCaptor.capture()); assertMessage(message, vertxMessageCaptor.getValue()); }
@Test public void shouldSendMessageWithAttachments() throws IOException { MailAttachment bufferAttachment = getAttachmentTemplate() .setData(Flux.just(getDataBuffer("Test buffer content 1"), getDataBuffer("Test buffer content 2"))); MailAttachment fileAttachment = getAttachmentTemplate() .setFile(getFile("Test file content 1")); MailAttachment inlineBufferAttachment = getAttachmentTemplate() .setData(Flux.just(getDataBuffer("Test buffer content 3"), getDataBuffer("Test buffer content 4"))); MailAttachment inlineFileAttachment = getAttachmentTemplate() .setFile(getFile("Test file content 2")); MailMessage message = new SimpleMailMessage() .addAttachment(bufferAttachment) .addAttachment(fileAttachment) .addInlineAttachment(inlineBufferAttachment) .addInlineAttachment(inlineFileAttachment); MailResult result = mailClient.send(message) .blockOptional() .orElseThrow(RuntimeException::new); assertThat(result.getMessageId()).isEqualTo("1"); assertThat(result.getRecipients()).containsOnly("to@example.com", "cc@example.com", "bcc@example.com"); ArgumentCaptor<io.vertx.ext.mail.MailMessage> vertxMessageCaptor = ArgumentCaptor.forClass(io.vertx.ext.mail.MailMessage.class); verify(mockMutinyMailClient).sendMail(vertxMessageCaptor.capture()); assertMessage(message, vertxMessageCaptor.getValue()); }
@Test public void shouldFailToSend() { given(mockMutinyMailClient.sendMail(any())).willReturn(Uni.createFrom().failure(new RuntimeException("test"))); Mono<MailResult> result = mailClient.send(new SimpleMailMessage()); StepVerifier.create(result) .expectNextCount(0) .expectErrorMessage("test") .verify(); }