Package com.ripariandata.timberwolf.mail

Examples of com.ripariandata.timberwolf.mail.MailboxItem


        int index = 0;
        List<String> ids = generateIds(0, itemsInExchange, getDefaultFolderId());
        while (mailIterator.hasNext())
        {
            MailboxItem item = mailIterator.next();
            assertEquals(ids.get(index), item.getHeader("Item ID"));
            index++;
            assertFolderSyncState(index, itemsInExchange, "");
        }
        assertFolderSyncState(itemsInExchange, itemsInExchange, newSyncState);
        assertEquals(itemsInExchange, index);
View Full Code Here


        int index = 0;
        List<String> ids = generateIds(0, itemsInExchange, getDefaultFolderId());
        while (mailIterator.hasNext())
        {
            MailboxItem item = mailIterator.next();
            assertEquals(ids.get(index), item.getHeader("Item ID"));
            index++;
            assertFolderSyncState(index, idPageSize, "");
            if (index > idPageSize)
            {
                assertFolderSyncState(index, itemsInExchange, secondSyncState);
View Full Code Here

        int index = 0;
        List<String> ids = generateIds(0, itemsInExchange, getDefaultFolderId());
        String expected = syncStates.remove(0);
        while (mailIterator.hasNext())
        {
            MailboxItem item = mailIterator.next();
            assertEquals(ids.get(index), item.getHeader("Item ID"));
            if (index > 0 && index % idPageSize == 0)
            {
                expected = syncStates.remove(0);
            }
            index++;
View Full Code Here

        int index = 0;
        List<String> ids = generateIds(0, itemsInExchange, getDefaultFolderId());
        String expected = syncStates.remove(0);
        while (mailIterator.hasNext())
        {
            MailboxItem item = mailIterator.next();
            assertEquals(ids.get(index), item.getHeader("Item ID"));
            if (index > 0 && index % idPageSize == 0)
            {
                expected = syncStates.remove(0);
            }
            index++;
View Full Code Here

        for (String folder : new String[]{"FOLDER-ONE-ID", "FOLDER-TWO-ID", "FOLDER-THREE-ID"})
        {
            for (int i = 0; i < (folder == "FOLDER-TWO-ID" ? folderIdTwoCount : folderIdOtherCount); i++)
            {
                assertTrue(mail.hasNext());
                MailboxItem item = mail.next();
                assertEquals(folder + ":the #" + i + " id", item.getHeader("Item ID"));
            }
        }
        assertFalse(mail.hasNext());
    }
View Full Code Here

        for (String folder : new String[]{bobFolderId, aliceFolderId})
        {
            for (int i = 0; i < count; i++)
            {
                assertTrue(mail.hasNext());
                MailboxItem item = mail.next();
                assertEquals(folder + ":the #" + i + " id", item.getHeader("Item ID"));
            }
        }
        assertFalse(mail.hasNext());
    }
View Full Code Here

        ExchangeMailStore store = new ExchangeMailStore(getService(), idPageSize, getItemPageSize);
        Iterator<MailboxItem> mail = store.getMail(users, mockSyncStates).iterator();
        for (int i = 0; i < totalMessageCount; i++)
        {
            assertTrue(mail.hasNext());
            MailboxItem item = mail.next();
            assertEquals("ALICE-FOLDER:the #" + i + " id", item.getHeader("Item ID"));
        }
        assertFalse(mail.hasNext());
        verify(mockSyncStates).setSyncState(aliceUsername, aliceFolderId, "syncState2");

        when(mockSyncStates.getLastSyncState(aliceUsername, aliceFolderId)).thenReturn("newSyncState");
        MessageType[] newMessages =
                mockSyncFolderItems(createMockMessages(aliceFolderId, 10, 2),
                                    folderContext(aliceUsername, aliceFolderId, "newSyncState"),
                                    idPageSize, "lastSyncState", true);
        mockGetItem(newMessages,
                    generateIds(10, 2, aliceFolderId),
                    aliceUsername);


        mail = store.getMail(users, mockSyncStates).iterator();
        for (int i = 10; i < 12; i++)
        {
            assertTrue(mail.hasNext());
            MailboxItem item = mail.next();
            assertEquals("ALICE-FOLDER:the #" + i + " id", item.getHeader("Item ID"));
        }
        assertFalse(mail.hasNext());
        verify(mockSyncStates).setSyncState(aliceUsername, aliceFolderId, "lastSyncState");
    }
View Full Code Here

     * @param mailboxItemDescription The above-mentioned dictionary.
     * @return A mock MailboxItem.
     */
    private MailboxItem mockMailboxItem(final Dictionary<String, String> mailboxItemDescription)
    {
        MailboxItem mailboxItem = mock(MailboxItem.class);

        Enumeration<String> keys = mailboxItemDescription.keys();
        String[] headers = new String[mailboxItemDescription.size()];
        headers = Collections.list(keys).toArray(headers);

        when(mailboxItem.getHeaderKeys()).thenReturn(headers);

        for (String header : headers)
        {
            String value = mailboxItemDescription.get(header);

            when(mailboxItem.getHeader(header)).thenReturn(value);
        }

        return mailboxItem;
    }
View Full Code Here

        String arbitraryFamily = "columnFamily";
        String arbitraryHeader = "header";

        Dictionary<String, String> mailboxItemDescription = generateMailboxItemDescription();
        MailboxItem mail = mockMailboxItem(mailboxItemDescription);

        List<MailboxItem> mails = new ArrayList<MailboxItem>();
        mails.add(mail);

        HBaseTable table = new HBaseTable(mockHTable);

        MailWriter writer = HBaseMailWriter.create(table, arbitraryHeader, arbitraryFamily);

        writer.write(mails);

        assertMailboxItemDescription(mockHTable, mailboxItemDescription, arbitraryFamily,
                mail.getHeader(arbitraryHeader));
    }
View Full Code Here

    private static MailboxItem mockMailboxItem(final String key, final String body, final String subject,
                                               final String timesent, final String sender, final String to,
                                               final String cc, final String bcc)
    {
        MailboxItem mail = mock(MailboxItem.class);
        ArrayList<String> headers = new ArrayList<String>();
        when(mail.hasKey(any(String.class))).thenReturn(true);
        when(mail.getHeader("Item ID")).thenReturn(key);
        if (body != null)
        {
            when(mail.getHeader("Body")).thenReturn(body);
            headers.add("Body");
        }
        if (subject != null)
        {
            when(mail.getHeader("Subject")).thenReturn(subject);
            headers.add("Subject");
        }
        if (timesent != null)
        {
            when(mail.getHeader("Time Sent")).thenReturn(timesent);
            headers.add("Time Sent");
        }
        if (sender != null)
        {
            when(mail.getHeader("Sender")).thenReturn(sender);
            headers.add("Sender");
        }
        if (to != null)
        {
            when(mail.getHeader("To")).thenReturn(to);
            headers.add("To");
        }
        if (cc != null)
        {
            when(mail.getHeader("Cc")).thenReturn(cc);
            headers.add("Cc");
        }
        if (bcc != null)
        {
            when(mail.getHeader("Bcc")).thenReturn(bcc);
            headers.add("Bcc");
        }
        when(mail.getHeaderKeys()).thenReturn(headers.toArray(new String[0]));
        return mail;
    }
View Full Code Here

TOP

Related Classes of com.ripariandata.timberwolf.mail.MailboxItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.