@Test public void processorShouldWorkOnExceptionThrown() throws Exception { GetQuotaRequest getQuotaRequest = new GetQuotaRequest(TAG, QUOTA_ROOT.getValue()); when(mockedQuotaRootResolver.retrieveAssociatedMailboxes(QUOTA_ROOT, mailboxSession)) .thenReturn(Flux.just((mailbox))); when(mockedMailboxManager.hasRight(MAILBOX_PATH, MailboxACL.Right.Read, mailboxSession)) .thenReturn(true); when(mockedQuotaManager.getMessageQuota(QUOTA_ROOT)).thenThrow(new MailboxException()); when(mockedQuotaManager.getStorageQuota(QUOTA_ROOT)).thenReturn(STORAGE_QUOTA); testee.doProcess(getQuotaRequest, mockedResponder, imapSession); ArgumentCaptor<ImapResponseMessage> argumentCaptor = ArgumentCaptor.forClass(ImapResponseMessage.class); verify(mockedResponder).respond(argumentCaptor.capture()); verifyNoMoreInteractions(mockedResponder); assertThat(argumentCaptor.getAllValues()) .hasSize(1) .allMatch(StatusResponseTypeMatcher.BAD_RESPONSE_MATCHER::matches); }
private boolean hasRight(QuotaRoot quotaRoot, ImapSession session) throws MailboxException { final MailboxSession mailboxSession = session.getMailboxSession(); List<Mailbox> mailboxList = Flux.from(quotaRootResolver.retrieveAssociatedMailboxes(quotaRoot, mailboxSession)) .collect(Guavate.toImmutableList()) .subscribeOn(Schedulers.elastic()) .block(); for (Mailbox mailbox : mailboxList) { if (getMailboxManager().hasRight(mailbox.generateAssociatedPath(), MailboxACL.Right.Read, mailboxSession)) { return true; } } return false; }
GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> implements CapabilityImplementingProcessor { private boolean hasRight(QuotaRoot quotaRoot, ImapSession session) throws MailboxException { final MailboxSession mailboxSession = session.getMailboxSession(); List<Mailbox> mailboxList = Flux.from(quotaRootResolver.retrieveAssociatedMailboxes(quotaRoot, mailboxSession)) .collect(Guavate.toImmutableList()) .subscribeOn(Schedulers.elastic()) .block(); for (Mailbox mailbox : mailboxList) { if (getMailboxManager().hasRight(mailbox.generateAssociatedPath(), MailboxACL.Right.Read, mailboxSession)) { return true; } } return false; } }
GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> implements CapabilityImplementingProcessor { private boolean hasRight(QuotaRoot quotaRoot, ImapSession session) throws MailboxException { final MailboxSession mailboxSession = session.getMailboxSession(); List<Mailbox> mailboxList = Flux.from(quotaRootResolver.retrieveAssociatedMailboxes(quotaRoot, mailboxSession)) .collect(Guavate.toImmutableList()) .subscribeOn(Schedulers.elastic()) .block(); for (Mailbox mailbox : mailboxList) { if (getMailboxManager().hasRight(mailbox.generateAssociatedPath(), MailboxACL.Right.Read, mailboxSession)) { return true; } } return false; } GetQuotaProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver,
            MetricFactory metricFactory); }
GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> implements CapabilityImplementingProcessor { private boolean hasRight(QuotaRoot quotaRoot, ImapSession session) throws MailboxException { final MailboxSession mailboxSession = session.getMailboxSession(); List<Mailbox> mailboxList = Flux.from(quotaRootResolver.retrieveAssociatedMailboxes(quotaRoot, mailboxSession)) .collect(Guavate.toImmutableList()) .subscribeOn(Schedulers.elastic()) .block(); for (Mailbox mailbox : mailboxList) { if (getMailboxManager().hasRight(mailbox.generateAssociatedPath(), MailboxACL.Right.Read, mailboxSession)) { return true; } } return false; } GetQuotaProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver,
            MetricFactory metricFactory); @Override List<Capability> getImplementedCapabilities(ImapSession session); }
GetQuotaProcessor extends AbstractMailboxProcessor<GetQuotaRequest> implements CapabilityImplementingProcessor { private boolean hasRight(QuotaRoot quotaRoot, ImapSession session) throws MailboxException { final MailboxSession mailboxSession = session.getMailboxSession(); List<Mailbox> mailboxList = Flux.from(quotaRootResolver.retrieveAssociatedMailboxes(quotaRoot, mailboxSession)) .collect(Guavate.toImmutableList()) .subscribeOn(Schedulers.elastic()) .block(); for (Mailbox mailbox : mailboxList) { if (getMailboxManager().hasRight(mailbox.generateAssociatedPath(), MailboxACL.Right.Read, mailboxSession)) { return true; } } return false; } GetQuotaProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory, QuotaManager quotaManager, QuotaRootResolver quotaRootResolver,
            MetricFactory metricFactory); @Override List<Capability> getImplementedCapabilities(ImapSession session);  }