Package com.ripariandata.timberwolf.mail

Examples of com.ripariandata.timberwolf.mail.MailboxItem


    {
        MessageType mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetSubject()).thenReturn(true);
        when(mockedMessage.getSubject()).thenReturn("Test Email");

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Subject"));
        assertEquals("Test Email", mail.getHeader("Subject"));

        mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetSubject()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Subject"));
        assertNull(mail.getHeader("Subject"));
    }
View Full Code Here


        when(mockedMessage.isSetDateTimeSent()).thenReturn(true);
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, day, hour, minute, second);
        when(mockedMessage.getDateTimeSent()).thenReturn(calendar);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertEquals("Jan 7, 2012 12:55:30 PM", mail.getHeader("Time Sent"));

        mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetDateTimeSent()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Time Sent"));
        assertNull(mail.getHeader("Time Sent"));
    }
View Full Code Here

        when(mockedMessage.isSetBody()).thenReturn(true);
        BodyType body = BodyType.Factory.newInstance();
        body.setStringValue("This is an email message.");
        when(mockedMessage.getBody()).thenReturn(body);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Body"));
        assertEquals("This is an email message.", mail.getHeader("Body"));

        mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetBody()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Body"));
        assertNull(mail.getHeader("Body"));
    }
View Full Code Here

        ItemIdType mockedId = mock(ItemIdType.class);
        when(mockedMessage.isSetItemId()).thenReturn(true);
        when(mockedMessage.getItemId()).thenReturn(mockedId);
        when(mockedId.getId()).thenReturn("ABCD1234");

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Item ID"));
        assertEquals("ABCD1234", mail.getHeader("Item ID"));

        mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetItemId()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Item ID"));
        assertNull(mail.getHeader("Item ID"));
    }
View Full Code Here

        when(mockedMessage.getFrom()).thenReturn(sender);
        when(sender.getMailbox()).thenReturn(address);
        when(address.isSetEmailAddress()).thenReturn(true);
        when(address.getEmailAddress()).thenReturn("seank@int.test");

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Sender"));
        assertEquals("seank@int.test", mail.getHeader("Sender"));

        mockedMessage = mock(MessageType.class);
        sender = mock(SingleRecipientType.class);
        address = mock(EmailAddressType.class);
        when(mockedMessage.isSetFrom()).thenReturn(true);
        when(mockedMessage.getFrom()).thenReturn(sender);
        when(sender.getMailbox()).thenReturn(address);
        when(address.isSetEmailAddress()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Sender"));
        assertNull(mail.getHeader("Sender"));

        mockedMessage = mock(MessageType.class);
        sender = mock(SingleRecipientType.class);
        address = mock(EmailAddressType.class);
        when(mockedMessage.isSetFrom()).thenReturn(false);
        when(mockedMessage.isSetSender()).thenReturn(true);
        when(mockedMessage.getSender()).thenReturn(sender);
        when(sender.getMailbox()).thenReturn(address);
        when(address.isSetEmailAddress()).thenReturn(true);
        when(address.getEmailAddress()).thenReturn("seank@int.test");

        mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Sender"));
        assertEquals("seank@int.test", mail.getHeader("Sender"));

        mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetFrom()).thenReturn(false);

        mail = new ExchangeEmail(mockedMessage);
        assertFalse(mail.hasKey("Sender"));
        assertNull(mail.getHeader("Sender"));
    }
View Full Code Here

        MessageType mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetToRecipients()).thenReturn(true);
        ArrayOfRecipientsType recipients = assertRecipients();
        when(mockedMessage.getToRecipients()).thenReturn(recipients);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("To"));
        assertEquals("email1@domain.com;email2@domain.com;", mail.getHeader("To"));
    }
View Full Code Here

        MessageType mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetCcRecipients()).thenReturn(true);
        ArrayOfRecipientsType recipients = assertRecipients();
        when(mockedMessage.getCcRecipients()).thenReturn(recipients);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Cc"));
        assertEquals("email1@domain.com;email2@domain.com;", mail.getHeader("Cc"));
    }
View Full Code Here

        MessageType mockedMessage = mock(MessageType.class);
        when(mockedMessage.isSetBccRecipients()).thenReturn(true);
        ArrayOfRecipientsType recipients = assertRecipients();
        when(mockedMessage.getBccRecipients()).thenReturn(recipients);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Bcc"));
        assertEquals("email1@domain.com;email2@domain.com;", mail.getHeader("Bcc"));
    }
View Full Code Here

        when(mockedMessage.getSubject()).thenReturn("Subject of an email.");
        when(mockedMessage.isSetToRecipients()).thenReturn(true);
        ArrayOfRecipientsType recipients = assertRecipients();
        when(mockedMessage.getToRecipients()).thenReturn(recipients);

        MailboxItem mail = new ExchangeEmail(mockedMessage);
        assertTrue(mail.hasKey("Body"));
        assertTrue(mail.hasKey("Subject"));
        assertFalse(mail.hasKey("Time Sent"));
        assertFalse(mail.hasKey("Item ID"));
        assertFalse(mail.hasKey("Sender"));
        assertTrue(mail.hasKey("To"));
        assertFalse(mail.hasKey("Cc"));
        assertFalse(mail.hasKey("Bcc"));

        String[] keys = mail.getHeaderKeys();
        final int keyLength = 3;
        assertEquals(keyLength, keys.length);
        assertEquals("Body", keys[0]);
        assertEquals("Subject", keys[1]);
        assertEquals("To", keys[2]);

        assertEquals("Body of an email.", mail.getHeader("Body"));
        assertEquals("Subject of an email.", mail.getHeader("Subject"));
        assertNull(mail.getHeader("Time Sent"));
        assertNull(mail.getHeader("Item ID"));
        assertNull(mail.getHeader("Sender"));
        assertEquals("email1@domain.com;email2@domain.com;", mail.getHeader("To"));
        assertNull(mail.getHeader("Cc"));
        assertNull(mail.getHeader("Bcc"));
    }
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, itemsInExchange, "");
        }
        assertFolderSyncState(itemsInExchange, itemsInExchange, newSyncState);
        assertEquals(itemsInExchange, index);
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.