Search in sources :

Example 1 with Folder

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

the class WebDavStoreTest method getPersonalNamespaces_shouldProvideListOfAllFoldersSentFromResponses.

@Test
public void getPersonalNamespaces_shouldProvideListOfAllFoldersSentFromResponses() throws Exception {
    StoreConfig storeConfig = createStoreConfig("webdav://user:password@example.org:80");
    WebDavStore webDavStore = new WebDavStore(storeConfig, mockHttpClientFactory);
    configureHttpResponses(UNAUTHORIZED_401_RESPONSE, OK_200_RESPONSE, createOkPropfindResponse(), createOkSearchResponse());
    List<? extends Folder> folders = webDavStore.getPersonalNamespaces(true);
    List<HttpGeneric> requests = requestCaptor.getAllValues();
    assertEquals(3, folders.size());
}
Also used : StoreConfig(com.fsck.k9.mail.store.StoreConfig) Test(org.junit.Test)

Example 2 with Folder

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

the class WebDavStoreTest method getFolder_calledTwice_shouldReturnFirstInstance.

@Test
public void getFolder_calledTwice_shouldReturnFirstInstance() throws Exception {
    WebDavStore webDavStore = createDefaultWebDavStore();
    String folderName = "Trash";
    Folder webDavFolder = webDavStore.getFolder(folderName);
    Folder result = webDavStore.getFolder(folderName);
    assertSame(webDavFolder, result);
}
Also used : Folder(com.fsck.k9.mail.Folder) Test(org.junit.Test)

Example 3 with Folder

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

the class ImapStoreTest method getFolder_calledTwice_shouldReturnFirstInstance.

@Test
public void getFolder_calledTwice_shouldReturnFirstInstance() throws Exception {
    String folderName = "Trash";
    Folder imapFolder = imapStore.getFolder(folderName);
    Folder result = imapStore.getFolder(folderName);
    assertEquals(imapFolder, result);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Folder(com.fsck.k9.mail.Folder) Test(org.junit.Test)

Example 4 with Folder

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

the class ImapStoreTest method getFolder_shouldReturnImapFolderInstance.

@Test
public void getFolder_shouldReturnImapFolderInstance() throws Exception {
    Folder result = imapStore.getFolder("INBOX");
    assertEquals(ImapFolder.class, result.getClass());
}
Also used : Folder(com.fsck.k9.mail.Folder) Test(org.junit.Test)

Example 5 with Folder

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

the class ImapFolderTest method fetchPart_withTextSection_shouldProcessImapResponses.

@Test
public void fetchPart_withTextSection_shouldProcessImapResponses() throws Exception {
    ImapFolder folder = createFolder("Folder");
    prepareImapFolderForOpen(OPEN_MODE_RO);
    folder.open(OPEN_MODE_RO);
    ImapMessage message = createImapMessage("1");
    Part part = createPlainTextPart("1.1");
    setupSingleFetchResponseToCallback();
    folder.fetchPart(message, part, null);
    ArgumentCaptor<Body> bodyArgumentCaptor = ArgumentCaptor.forClass(Body.class);
    verify(part).setBody(bodyArgumentCaptor.capture());
    Body body = bodyArgumentCaptor.getValue();
    Buffer buffer = new Buffer();
    body.writeTo(buffer.outputStream());
    assertEquals("text", buffer.readUtf8());
}
Also used : Buffer(okio.Buffer) Part(com.fsck.k9.mail.Part) Body(com.fsck.k9.mail.Body) BinaryTempFileBody(com.fsck.k9.mail.internet.BinaryTempFileBody) Test(org.junit.Test)

Aggregations

MessagingException (com.fsck.k9.mail.MessagingException)51 LocalFolder (com.fsck.k9.mailstore.LocalFolder)50 LocalStore (com.fsck.k9.mailstore.LocalStore)39 Test (org.junit.Test)39 Folder (com.fsck.k9.mail.Folder)37 FetchProfile (com.fsck.k9.mail.FetchProfile)26 LocalMessage (com.fsck.k9.mailstore.LocalMessage)25 Message (com.fsck.k9.mail.Message)20 ArrayList (java.util.ArrayList)20 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)19 Account (com.fsck.k9.Account)18 AuthenticationFailedException (com.fsck.k9.mail.AuthenticationFailedException)17 Date (java.util.Date)15 CertificateValidationException (com.fsck.k9.mail.CertificateValidationException)13 IOException (java.io.IOException)13 SuppressLint (android.annotation.SuppressLint)12 Store (com.fsck.k9.mail.Store)12 HashMap (java.util.HashMap)12 Pop3Store (com.fsck.k9.mail.store.pop3.Pop3Store)11 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)11