MessageIdReIndexerImpl implements MessageIdReIndexer { @Override public Task reIndex(MessageId messageId) { return new MessageIdReIndexingTask(reIndexerPerformer, messageId); } @Inject  MessageIdReIndexerImpl(ReIndexerPerformer reIndexerPerformer); @Override Task reIndex(MessageId messageId);  }
@Test void reIndexShouldBeWellPerformed() throws Exception { MailboxSession systemSession = mailboxManager.createSystemSession(USERNAME); MailboxId mailboxId = mailboxManager.createMailbox(INBOX, systemSession).get(); ComposedMessageId createdMessage = mailboxManager.getMailbox(INBOX, systemSession) .appendMessage( MessageManager.AppendCommand.builder().build("header: value\r\n\r\nbody"), systemSession).getId(); reIndexer.reIndex(createdMessage.getMessageId()).run(); ArgumentCaptor<MailboxMessage> messageCaptor = ArgumentCaptor.forClass(MailboxMessage.class); ArgumentCaptor<Mailbox> mailboxCaptor = ArgumentCaptor.forClass(Mailbox.class); verify(messageSearchIndex).add(any(MailboxSession.class), mailboxCaptor.capture(), messageCaptor.capture()); verifyNoMoreInteractions(messageSearchIndex); assertThat(mailboxCaptor.getValue()).matches(mailbox -> mailbox.getMailboxId().equals(mailboxId)); assertThat(messageCaptor.getValue()).matches(message -> message.getComposedMessageIdWithMetaData().getComposedMessageId().getMessageId() .equals(createdMessage.getMessageId())); }