@Test public void processShouldWork() throws Exception { MoveRequest moveRequest = new MoveRequest(new IdRange[] {new IdRange(4, 6)}, ImapConstants.INBOX_NAME, true, TAG); MailboxPath selected = new MailboxPath(INBOX, "selected"); SelectedMailbox selectedMailbox = mock(SelectedMailbox.class); when(selectedMailbox.getLastUid()).thenReturn(Optional.of(MessageUid.of(8))); when(selectedMailbox.existsCount()).thenReturn(8L); when(selectedMailbox.getPath()).thenReturn(selected); imapSession.selected(selectedMailbox); when(mockMailboxManager.mailboxExists(INBOX, mailboxSession)).thenReturn(Mono.just(true)); MessageManager targetMessageManager = mock(MessageManager.class); when(mockMailboxManager.getMailbox(INBOX, mailboxSession)).thenReturn(targetMessageManager); Mailbox mailbox = mock(Mailbox.class); when(mailbox.getUidValidity()).thenReturn(UID_VALIDITY); when(targetMessageManager.getMailboxEntity()).thenReturn(mailbox); StatusResponse okResponse = mock(StatusResponse.class); when(mockStatusResponseFactory.taggedOk(any(Tag.class), any(ImapCommand.class), any(HumanReadableText.class), any(StatusResponse.ResponseCode.class))).thenReturn(okResponse); when(mockMailboxManager.moveMessages(MessageRange.range(MessageUid.of(4), MessageUid.of(6)), selected, INBOX, mailboxSession)) .thenReturn(Lists.<MessageRange>newArrayList(MessageRange.range(MessageUid.of(4), MessageUid.of(6)))); testee.process(moveRequest, mockResponder, imapSession); verify(mockMailboxManager).startProcessingRequest(mailboxSession); verify(mockMailboxManager).endProcessingRequest(mailboxSession); verify(mockMailboxManager).mailboxExists(INBOX, mailboxSession); verify(mockMailboxManager).getMailbox(INBOX, mailboxSession); verify(mockMailboxManager).moveMessages(MessageRange.range(MessageUid.of(4), MessageUid.of(6)), selected, INBOX, mailboxSession); verify(targetMessageManager).getMailboxEntity(); verify(mockResponder).respond(okResponse); verifyNoMoreInteractions(mockMailboxManager, targetMessageManager, mockResponder, mockNextProcessor); }
@Override protected List<MessageRange> process(MailboxPath targetMailbox, SelectedMailbox currentMailbox, MailboxSession mailboxSession, MessageRange messageSet) throws MailboxException { return getMailboxManager().moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession); }
MoveProcessor extends AbstractMessageRangeProcessor<MoveRequest> implements CapabilityImplementingProcessor { @Override protected List<MessageRange> process(MailboxPath targetMailbox, SelectedMailbox currentMailbox, MailboxSession mailboxSession, MessageRange messageSet) throws MailboxException { return getMailboxManager().moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession); } }
MoveProcessor extends AbstractMessageRangeProcessor<MoveRequest> implements CapabilityImplementingProcessor { @Override protected List<MessageRange> process(MailboxPath targetMailbox, SelectedMailbox currentMailbox, MailboxSession mailboxSession, MessageRange messageSet) throws MailboxException { return getMailboxManager().moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession); } MoveProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory,
            MetricFactory metricFactory); }
MoveProcessor extends AbstractMessageRangeProcessor<MoveRequest> implements CapabilityImplementingProcessor { @Override protected List<MessageRange> process(MailboxPath targetMailbox, SelectedMailbox currentMailbox, MailboxSession mailboxSession, MessageRange messageSet) throws MailboxException { return getMailboxManager().moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession); } MoveProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory,
            MetricFactory metricFactory); @Override List<Capability> getImplementedCapabilities(ImapSession session); }
MoveProcessor extends AbstractMessageRangeProcessor<MoveRequest> implements CapabilityImplementingProcessor { @Override protected List<MessageRange> process(MailboxPath targetMailbox, SelectedMailbox currentMailbox, MailboxSession mailboxSession, MessageRange messageSet) throws MailboxException { return getMailboxManager().moveMessages(messageSet, currentMailbox.getPath(), targetMailbox, mailboxSession); } MoveProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory,
            MetricFactory metricFactory); @Override List<Capability> getImplementedCapabilities(ImapSession session);  }