@Override public AnnotationMapper createAnnotationMapper() throws MailboxException { return inMemoryMailboxSessionMapperFactory.createAnnotationMapper(MAILBOX_SESSION); }
@Override public AttachmentMapper createAttachmentMapper() throws MailboxException { return inMemoryMailboxSessionMapperFactory.createAttachmentMapper(MAILBOX_SESSION); }
@Override public MessageIdMapper createMessageIdMapper() throws MailboxException { return new InMemoryMessageIdMapper( inMemoryMailboxSessionMapperFactory.createMailboxMapper(MAILBOX_SESSION), inMemoryMailboxSessionMapperFactory.createMessageMapper(MAILBOX_SESSION)); }
public InMemoryMapperProvider() { random = new Random(); messageIdFactory = new InMemoryMessageId.Factory(); messageUidProvider = new MessageUidProvider(); inMemoryMailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory(); }
@Before public void setup() throws MailboxException { spamAssassin = mock(SpamAssassin.class); InMemoryMailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory(); mailboxMapper = mapperFactory.getMailboxMapper(MAILBOX_SESSION); inbox = new SimpleMailbox(MailboxPath.forUser(USER, DefaultMailboxes.INBOX), UID_VALIDITY); inboxId = mailboxMapper.save(inbox); mailbox1 = new SimpleMailbox(MailboxPath.forUser(USER, "mailbox1"), UID_VALIDITY); mailboxId1 = mailboxMapper.save(mailbox1); mailboxId2 = mailboxMapper.save(new SimpleMailbox(MailboxPath.forUser(USER, "mailbox2"), UID_VALIDITY)); spamMailboxId = mailboxMapper.save(new SimpleMailbox(MailboxPath.forUser(USER, "Spam"), UID_VALIDITY)); spamCapitalMailboxId = mailboxMapper.save(new SimpleMailbox(MailboxPath.forUser(USER, "SPAM"), UID_VALIDITY)); trashMailboxId = mailboxMapper.save(new SimpleMailbox(MailboxPath.forUser(USER, "Trash"), UID_VALIDITY)); listener = new SpamAssassinListener(spamAssassin, mapperFactory, MailboxListener.ExecutionMode.SYNCHRONOUS); }
@Override public long highestModSeq(Mailbox mailbox) throws MailboxException { return inMemoryMailboxSessionMapperFactory.getModSeqProvider() .highestModSeq(MAILBOX_SESSION, mailbox); }
@Override public MailboxMapper createMailboxMapper() throws MailboxException { return inMemoryMailboxSessionMapperFactory.createMailboxMapper(MAILBOX_SESSION); }
@Override protected void storeAttachment(final MailboxMessage message, final List<MessageAttachment> messageAttachments, final MailboxSession session) throws MailboxException { mapperFactory.getAttachmentMapper(session) .storeAttachmentsForMessage( messageAttachments.stream() .map(MessageAttachment::getAttachment) .collect(Guavate.toImmutableList()), message.getMessageId()); } }
@Override public MessageMapper createMessageMapper() throws MailboxException { return inMemoryMailboxSessionMapperFactory.createMessageMapper(new MockMailboxSession("user")); }
@Override @Before public void setUp() throws Exception { mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory(); Authenticator noAuthenticator = null; Authorizator noAuthorizator = null; DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener(); MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener); MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory(); GroupMembershipResolver groupMembershipResolver = null; UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver(); StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher); StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager); mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager); mailboxManager.init(); MessageParser failingMessageParser = mock(MessageParser.class); when(failingMessageParser.retrieveAttachments(any(InputStream.class))) .thenThrow(new RuntimeException("Message parser set to fail")); parseFailingMailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), failingMessageParser, messageIdFactory, mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager); parseFailingMailboxManager.init(); super.setUp(); }
@Override public long generateModSeq(Mailbox mailbox) throws MailboxException { return inMemoryMailboxSessionMapperFactory.getModSeqProvider() .nextModSeq(MAILBOX_SESSION, mailbox); }
fakeAuthenticator.addUser(ManagerTestResources.USER, ManagerTestResources.USER_PASS); fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS); InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory(); DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener(); MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
public StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver, Authenticator authenticator, Authorizator authorizator) throws MailboxException { InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory(); DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener(); MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener); StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver, mailboxEventDispatcher); StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager); StoreMailboxManager manager = new InMemoryMailboxManager( mailboxSessionMapperFactory, authenticator, authorizator, new NoMailboxPathLocker(), new MessageParser(), new InMemoryMessageId.Factory(), mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager); manager.init(); return manager; }
@Override protected MessageIdManagerTestSystem createTestSystem(QuotaManager quotaManager, MailboxEventDispatcher dispatcher) { InMemoryMailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();