Search in sources :

Example 11 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateSetFlag_oldFormat.

@Test
public void migrateSetFlag_oldFormat() {
    OldPendingCommand command = queueSetFlagOld(SOURCE_FOLDER, FLAG_STATE, FLAG, UID);
    PendingSetFlag pendingCommand = (PendingSetFlag) MigrationTo60.migratePendingCommand(command);
    assertEquals(SOURCE_FOLDER, pendingCommand.folder);
    assertEquals(FLAG_STATE, pendingCommand.newState);
    assertEquals(FLAG, pendingCommand.flag);
    assertEquals(Collections.singletonList(UID), pendingCommand.uids);
}
Also used : PendingSetFlag(com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) Test(org.junit.Test)

Example 12 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateMoveOrCopy_withUidArray.

@Test
public void migrateMoveOrCopy_withUidArray() {
    OldPendingCommand command = queueMoveOrCopy(SOURCE_FOLDER, DEST_FOLDER, IS_COPY, UID_ARRAY);
    PendingMoveOrCopy pendingCommand = (PendingMoveOrCopy) MigrationTo60.migratePendingCommand(command);
    assertEquals(SOURCE_FOLDER, pendingCommand.srcFolder);
    assertEquals(DEST_FOLDER, pendingCommand.destFolder);
    assertEquals(IS_COPY, pendingCommand.isCopy);
    assertEquals(asList(UID_ARRAY), pendingCommand.uids);
    assertNull(pendingCommand.newUidMap);
}
Also used : PendingMoveOrCopy(com.fsck.k9.controller.MessagingControllerCommands.PendingMoveOrCopy) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) Test(org.junit.Test)

Example 13 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class PendingCommandSerializerTest method testDeserialize__withUnknownCommandName__shouldFail.

@Test(expected = IllegalArgumentException.class)
public void testDeserialize__withUnknownCommandName__shouldFail() {
    PendingCommand pendingCommand = PendingEmptyTrash.create();
    String serializedCommand = pendingCommandSerializer.serialize(pendingCommand);
    pendingCommandSerializer.unserialize(DATABASE_ID, "BAD_COMMAND_NAME", serializedCommand);
}
Also used : PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand) Test(org.junit.Test)

Example 14 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class PendingCommandSerializerTest method testSerializeDeserialize__withoutArguments.

@Test
public void testSerializeDeserialize__withoutArguments() {
    PendingCommand pendingCommand = PendingEmptyTrash.create();
    String serializedCommand = pendingCommandSerializer.serialize(pendingCommand);
    PendingEmptyTrash unserializedCommand = (PendingEmptyTrash) pendingCommandSerializer.unserialize(DATABASE_ID, pendingCommand.getCommandName(), serializedCommand);
    assertEquals(DATABASE_ID, unserializedCommand.databaseId);
}
Also used : PendingEmptyTrash(com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash) PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand) Test(org.junit.Test)

Example 15 with PendingCommand

use of com.fsck.k9.controller.MessagingControllerCommands.PendingCommand in project k-9 by k9mail.

the class MessagingController method moveOrDeleteSentMessage.

private void moveOrDeleteSentMessage(Account account, LocalStore localStore, LocalFolder localFolder, LocalMessage message) throws MessagingException {
    if (!account.hasSentFolder()) {
        Timber.i("Account does not have a sent mail folder; deleting sent message");
        message.setFlag(Flag.DELETED, true);
    } else {
        LocalFolder localSentFolder = localStore.getFolder(account.getSentFolderName());
        Timber.i("Moving sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
        localFolder.moveMessages(Collections.singletonList(message), localSentFolder);
        Timber.i("Moved sent message to folder '%s' (%d)", account.getSentFolderName(), localSentFolder.getId());
        PendingCommand command = PendingAppend.create(localSentFolder.getName(), message.getUid());
        queuePendingCommand(account, command);
        processPendingCommands(account);
    }
}
Also used : LocalFolder(com.fsck.k9.mailstore.LocalFolder) PendingCommand(com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)

Aggregations

PendingCommand (com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)14 Test (org.junit.Test)14 OldPendingCommand (com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)10 PendingMoveOrCopy (com.fsck.k9.controller.MessagingControllerCommands.PendingMoveOrCopy)5 PendingSetFlag (com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag)4 MessagingException (com.fsck.k9.mail.MessagingException)4 LocalStore (com.fsck.k9.mailstore.LocalStore)4 LocalFolder (com.fsck.k9.mailstore.LocalFolder)3 ContentValues (android.content.ContentValues)2 PendingAppend (com.fsck.k9.controller.MessagingControllerCommands.PendingAppend)2 PendingEmptyTrash (com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash)2 Flag (com.fsck.k9.mail.Flag)2 Message (com.fsck.k9.mail.Message)2 MimeMessage (com.fsck.k9.mail.internet.MimeMessage)2 LocalMessage (com.fsck.k9.mailstore.LocalMessage)2 UnavailableStorageException (com.fsck.k9.mailstore.UnavailableStorageException)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SuppressLint (android.annotation.SuppressLint)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1