@Test public void matchShouldKeepAddressesWithTooBigSize() throws Exception { maxQuotaManager.setGlobalMaxStorage(QuotaSizeLimit.size(100)); FakeMail fakeMail = FakeMail.builder() .name("name") .recipient(MailAddressFixture.ANY_AT_JAMES) .size(1000) .build(); Collection<MailAddress> result = testee.match(fakeMail); assertThat(result).containsOnly(MailAddressFixture.ANY_AT_JAMES); }
@Override public Collection<MailAddress> match(Mail mail) throws MessagingException { try { List<MailAddress> result = new ArrayList<>(); for (MailAddress mailAddress : mail.getRecipients()) { Username userName = usersRepository.getUsername(mailAddress); MailboxPath mailboxPath = MailboxPath.inbox(userName); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); if (quotaManager.getMessageQuota(quotaRoot).isOverQuotaWithAdditionalValue(SINGLE_EMAIL) || quotaManager.getStorageQuota(quotaRoot).isOverQuotaWithAdditionalValue(mail.getMessageSize())) { result.add(mailAddress); } } return result; } catch (MailboxException e) { throw new MessagingException("Exception while checking quotas", e); } catch (UsersRepositoryException e) { throw new MessagingException("Exception while retrieving username", e); } }
IsOverQuota extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { try { List<MailAddress> result = new ArrayList<>(); for (MailAddress mailAddress : mail.getRecipients()) { Username userName = usersRepository.getUsername(mailAddress); MailboxPath mailboxPath = MailboxPath.inbox(userName); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); if (quotaManager.getMessageQuota(quotaRoot).isOverQuotaWithAdditionalValue(SINGLE_EMAIL) || quotaManager.getStorageQuota(quotaRoot).isOverQuotaWithAdditionalValue(mail.getMessageSize())) { result.add(mailAddress); } } return result; } catch (MailboxException e) { throw new MessagingException("Exception while checking quotas", e); } catch (UsersRepositoryException e) { throw new MessagingException("Exception while retrieving username", e); } } }
IsOverQuota extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { try { List<MailAddress> result = new ArrayList<>(); for (MailAddress mailAddress : mail.getRecipients()) { Username userName = usersRepository.getUsername(mailAddress); MailboxPath mailboxPath = MailboxPath.inbox(userName); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); if (quotaManager.getMessageQuota(quotaRoot).isOverQuotaWithAdditionalValue(SINGLE_EMAIL) || quotaManager.getStorageQuota(quotaRoot).isOverQuotaWithAdditionalValue(mail.getMessageSize())) { result.add(mailAddress); } } return result; } catch (MailboxException e) { throw new MessagingException("Exception while checking quotas", e); } catch (UsersRepositoryException e) { throw new MessagingException("Exception while retrieving username", e); } } @Inject  IsOverQuota(QuotaRootResolver quotaRootResolver, QuotaManager quotaManager, UsersRepository usersRepository); }
IsOverQuota extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { try { List<MailAddress> result = new ArrayList<>(); for (MailAddress mailAddress : mail.getRecipients()) { Username userName = usersRepository.getUsername(mailAddress); MailboxPath mailboxPath = MailboxPath.inbox(userName); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); if (quotaManager.getMessageQuota(quotaRoot).isOverQuotaWithAdditionalValue(SINGLE_EMAIL) || quotaManager.getStorageQuota(quotaRoot).isOverQuotaWithAdditionalValue(mail.getMessageSize())) { result.add(mailAddress); } } return result; } catch (MailboxException e) { throw new MessagingException("Exception while checking quotas", e); } catch (UsersRepositoryException e) { throw new MessagingException("Exception while retrieving username", e); } } @Inject  IsOverQuota(QuotaRootResolver quotaRootResolver, QuotaManager quotaManager, UsersRepository usersRepository); @Override Collection<MailAddress> match(Mail mail); }
IsOverQuota extends GenericMatcher { @Override public Collection<MailAddress> match(Mail mail) throws MessagingException { try { List<MailAddress> result = new ArrayList<>(); for (MailAddress mailAddress : mail.getRecipients()) { Username userName = usersRepository.getUsername(mailAddress); MailboxPath mailboxPath = MailboxPath.inbox(userName); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(mailboxPath); if (quotaManager.getMessageQuota(quotaRoot).isOverQuotaWithAdditionalValue(SINGLE_EMAIL) || quotaManager.getStorageQuota(quotaRoot).isOverQuotaWithAdditionalValue(mail.getMessageSize())) { result.add(mailAddress); } } return result; } catch (MailboxException e) { throw new MessagingException("Exception while checking quotas", e); } catch (UsersRepositoryException e) { throw new MessagingException("Exception while retrieving username", e); } } @Inject  IsOverQuota(QuotaRootResolver quotaRootResolver, QuotaManager quotaManager, UsersRepository usersRepository); @Override Collection<MailAddress> match(Mail mail);  }