Search in sources :

Example 16 with OldPendingCommand

use of com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method queueMoveOrCopy.

OldPendingCommand queueMoveOrCopy(String srcFolder, String destFolder, boolean isCopy, Map<String, String> uidMap) {
    OldPendingCommand command = new OldPendingCommand();
    command.command = PENDING_COMMAND_MOVE_OR_COPY_BULK_NEW;
    int length = 4 + uidMap.keySet().size() + uidMap.values().size();
    command.arguments = new String[length];
    command.arguments[0] = srcFolder;
    command.arguments[1] = destFolder;
    command.arguments[2] = Boolean.toString(isCopy);
    command.arguments[3] = Boolean.toString(true);
    Set<String> strings = uidMap.keySet();
    System.arraycopy(strings.toArray(new String[strings.size()]), 0, command.arguments, 4, uidMap.keySet().size());
    Collection<String> values = uidMap.values();
    System.arraycopy(values.toArray(new String[values.size()]), 0, command.arguments, 4 + uidMap.keySet().size(), uidMap.values().size());
    return command;
}
Also used : OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)

Example 17 with OldPendingCommand

use of com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateMarkAllMessagesRead.

@Test
public void migrateMarkAllMessagesRead() {
    OldPendingCommand command = queueMarkAllMessagesRead(SOURCE_FOLDER);
    PendingMarkAllAsRead pendingCommand = (PendingMarkAllAsRead) MigrationTo60.migratePendingCommand(command);
    assertEquals(SOURCE_FOLDER, pendingCommand.folder);
}
Also used : PendingMarkAllAsRead(com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead) OldPendingCommand(com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand) Test(org.junit.Test)

Example 18 with OldPendingCommand

use of com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateMoveOrCopy_withOldFormat.

@Test
public void migrateMoveOrCopy_withOldFormat() {
    OldPendingCommand command = queueMoveOrCopyOld(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 19 with OldPendingCommand

use of com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateSetFlag.

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

Example 20 with OldPendingCommand

use of com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand in project k-9 by k9mail.

the class MigrationTo60Test method migrateMoveOrCopy_withUidMap.

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

Aggregations

OldPendingCommand (com.fsck.k9.mailstore.migrations.MigrationTo60.OldPendingCommand)20 Test (org.junit.Test)10 PendingMoveOrCopy (com.fsck.k9.controller.MessagingControllerCommands.PendingMoveOrCopy)4 PendingSetFlag (com.fsck.k9.controller.MessagingControllerCommands.PendingSetFlag)4 PendingCommand (com.fsck.k9.controller.MessagingControllerCommands.PendingCommand)2 Flag (com.fsck.k9.mail.Flag)2 ArrayList (java.util.ArrayList)2 ContentValues (android.content.ContentValues)1 PendingAppend (com.fsck.k9.controller.MessagingControllerCommands.PendingAppend)1 PendingEmptyTrash (com.fsck.k9.controller.MessagingControllerCommands.PendingEmptyTrash)1 PendingExpunge (com.fsck.k9.controller.MessagingControllerCommands.PendingExpunge)1 PendingMarkAllAsRead (com.fsck.k9.controller.MessagingControllerCommands.PendingMarkAllAsRead)1 PendingCommandSerializer (com.fsck.k9.controller.PendingCommandSerializer)1