@Test public void matchShouldSupportVirtualHosting() throws Exception { when(usersRepository.getUser(MailAddressFixture.ANY_AT_JAMES)).thenReturn(MailAddressFixture.ANY_AT_JAMES.asString()); when(usersRepository.getUser(MailAddressFixture.OTHER_AT_JAMES)).thenReturn(MailAddressFixture.OTHER_AT_JAMES.asString()); String username = MailAddressFixture.ANY_AT_JAMES.asString(); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(MailboxPath.inbox(mailboxManager.createSystemSession(username))); maxQuotaManager.setMaxStorage(quotaRoot, QuotaSize.size(100)); FakeMail fakeMail = FakeMail.builder() .recipient(MailAddressFixture.ANY_AT_JAMES) .recipient(MailAddressFixture.OTHER_AT_JAMES) .size(150) .build(); Collection<MailAddress> result = testee.match(fakeMail); assertThat(result).containsOnly(MailAddressFixture.ANY_AT_JAMES); }
@Test public void matchShouldNotIncludeRecipientNotOverQuota() throws Exception { String username = MailAddressFixture.ANY_AT_JAMES.getLocalPart(); QuotaRoot quotaRoot = quotaRootResolver.getQuotaRoot(MailboxPath.inbox(mailboxManager.createSystemSession(username))); maxQuotaManager.setMaxStorage(quotaRoot, QuotaSize.size(100)); FakeMail fakeMail = FakeMail.builder() .recipient(MailAddressFixture.ANY_AT_JAMES) .recipient(MailAddressFixture.OTHER_AT_JAMES) .size(150) .build(); Collection<MailAddress> result = testee.match(fakeMail); assertThat(result).containsOnly(MailAddressFixture.ANY_AT_JAMES); }