Search in sources :

Example 51 with Part

use of com.fsck.k9.mail.Part in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_shouldStripQuoteHeaderAndQuotedText.

@Test
public void extractPreview_shouldStripQuoteHeaderAndQuotedText() throws Exception {
    String text = "" + "some text\r\n" + "On 01/02/03 someone wrote\r\n" + "> some quoted text\r\n" + "# some other quoted text\r\n";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals("some text", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 52 with Part

use of com.fsck.k9.mail.Part in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_withLongTextPlain.

@Test
public void extractPreview_withLongTextPlain() throws Exception {
    String text = "" + "10--------20--------30--------40--------50--------" + "60--------70--------80--------90--------100-------" + "110-------120-------130-------140-------150-------" + "160-------170-------180-------190-------200-------" + "210-------220-------230-------240-------250-------" + "260-------270-------280-------290-------300-------" + "310-------320-------330-------340-------350-------" + "360-------370-------380-------390-------400-------" + "410-------420-------430-------440-------450-------" + "460-------470-------480-------490-------500-------" + "510-------520-------";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals(text.substring(0, 511) + "…", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 53 with Part

use of com.fsck.k9.mail.Part in project k-9 by k9mail.

the class PreviewTextExtractorTest method extractPreview_shouldStripGenericQuoteHeader.

@Test
public void extractPreview_shouldStripGenericQuoteHeader() throws Exception {
    String text = "" + "Am 13.12.2015 um 23:42 schrieb Hans:\r\n" + "> hallo\r\n" + "hi there\r\n";
    Part part = createTextPart("text/plain", text);
    String preview = previewTextExtractor.extractPreview(part);
    assertEquals("hi there", preview);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) MessageCreationHelper.createTextPart(com.fsck.k9.message.MessageCreationHelper.createTextPart) Test(org.junit.Test)

Example 54 with Part

use of com.fsck.k9.mail.Part in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfoForDb__withNoBody__shouldReturnContentNotAvailable.

@Test
public void extractInfoForDb__withNoBody__shouldReturnContentNotAvailable() throws Exception {
    MimeBodyPart part = new MimeBodyPart();
    AttachmentViewInfo attachmentViewInfo = attachmentInfoExtractor.extractAttachmentInfoForDatabase(part);
    assertFalse(attachmentViewInfo.isContentAvailable);
}
Also used : MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) AttachmentViewInfo(com.fsck.k9.mailstore.AttachmentViewInfo) Test(org.junit.Test)

Example 55 with Part

use of com.fsck.k9.mail.Part in project k-9 by k9mail.

the class AttachmentInfoExtractorTest method extractInfo__withGenericPart_shouldThrow.

@Test(expected = IllegalArgumentException.class)
public void extractInfo__withGenericPart_shouldThrow() throws Exception {
    Part part = mock(Part.class);
    attachmentInfoExtractor.extractAttachmentInfo(part);
}
Also used : Part(com.fsck.k9.mail.Part) MimeBodyPart(com.fsck.k9.mail.internet.MimeBodyPart) LocalBodyPart(com.fsck.k9.mailstore.LocalBodyPart) Test(org.junit.Test)

Aggregations

Part (com.fsck.k9.mail.Part)113 Test (org.junit.Test)92 MimeBodyPart (com.fsck.k9.mail.internet.MimeBodyPart)78 BodyPart (com.fsck.k9.mail.BodyPart)73 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)39 Message (com.fsck.k9.mail.Message)32 MessageCreationHelper.createTextPart (com.fsck.k9.message.MessageCreationHelper.createTextPart)30 Body (com.fsck.k9.mail.Body)29 Multipart (com.fsck.k9.mail.Multipart)27 ArrayList (java.util.ArrayList)27 MimeMultipart (com.fsck.k9.mail.internet.MimeMultipart)20 MessageCreationHelper.createEmptyPart (com.fsck.k9.message.MessageCreationHelper.createEmptyPart)19 MessagingException (com.fsck.k9.mail.MessagingException)16 MessageCreationHelper.createPart (com.fsck.k9.message.MessageCreationHelper.createPart)16 TextBody (com.fsck.k9.mail.internet.TextBody)14 AttachmentViewInfo (com.fsck.k9.mailstore.AttachmentViewInfo)13 Viewable (com.fsck.k9.mail.internet.Viewable)10 Uri (android.net.Uri)8 BinaryTempFileBody (com.fsck.k9.mail.internet.BinaryTempFileBody)6 BinaryMemoryBody (com.fsck.k9.mailstore.BinaryMemoryBody)6