Search in sources :

Example 6 with DeleteFileSystemAction

use of org.syncany.operations.down.actions.DeleteFileSystemAction in project syncany by syncany.

the class FileSystemActionComparatorTest method testFileSystemActionComparator.

// TODO [low] write more unit tests for FileSystemActionComparator
@Test
public void testFileSystemActionComparator() throws Exception {
    // Setup
    List<FileSystemAction> actions = new ArrayList<FileSystemAction>();
    actions.add(createNewFileSystemAction("deletedfolderXX", FileType.FILE));
    actions.add(createNewFileSystemAction("newsymlink", FileType.SYMLINK));
    actions.add(createNewFileSystemAction("NEWfolder", FileType.FOLDER));
    actions.add(createNewFileSystemAction("newfile.jpg", FileType.FILE));
    // << same as folder above!
    actions.add(createDeleteFileSystemAction("deletedfolderXX", FileType.FOLDER));
    actions.add(createDeleteFileSystemAction("deletedsymlink.jpg", FileType.SYMLINK));
    actions.add(createNewFileSystemAction("newfile2.jpg", FileType.FILE));
    actions.add(createRenameFileSystemAction("from.jpg", "to.jpg", FileType.FILE));
    actions.add(createDeleteFileSystemAction("deletedfile2.jpg", FileType.FILE));
    // Run
    FileSystemActionComparator actionComparator = new FileSystemActionComparator();
    actionComparator.sort(actions);
    // Test
    assertArrayEquals("Actions should match order", new String[] { "DeleteFileSystemAction,deletedfile2.jpg,FILE", "DeleteFileSystemAction,deletedsymlink.jpg,SYMLINK", "NewFileSystemAction,NEWfolder,FOLDER", "NewFileSystemAction,newfile.jpg,FILE", "NewFileSystemAction,newfile2.jpg,FILE", "NewFileSystemAction,newsymlink,SYMLINK", "RenameFileSystemAction,to.jpg,FILE", "DeleteFileSystemAction,deletedfolderXX,FOLDER", // <<< moved here by postCompareSort!						
    "NewFileSystemAction,deletedfolderXX,FILE" }, toArray(actions));
    System.out.println(actions);
}
Also used : RenameFileSystemAction(org.syncany.operations.down.actions.RenameFileSystemAction) FileSystemAction(org.syncany.operations.down.actions.FileSystemAction) NewFileSystemAction(org.syncany.operations.down.actions.NewFileSystemAction) DeleteFileSystemAction(org.syncany.operations.down.actions.DeleteFileSystemAction) ArrayList(java.util.ArrayList) FileSystemActionComparator(org.syncany.operations.down.FileSystemActionComparator) Test(org.junit.Test)

Aggregations

DeleteFileSystemAction (org.syncany.operations.down.actions.DeleteFileSystemAction)6 FileSystemAction (org.syncany.operations.down.actions.FileSystemAction)5 NewFileSystemAction (org.syncany.operations.down.actions.NewFileSystemAction)5 RenameFileSystemAction (org.syncany.operations.down.actions.RenameFileSystemAction)5 ChangeFileSystemAction (org.syncany.operations.down.actions.ChangeFileSystemAction)3 NewSymlinkFileSystemAction (org.syncany.operations.down.actions.NewSymlinkFileSystemAction)3 SetAttributesFileSystemAction (org.syncany.operations.down.actions.SetAttributesFileSystemAction)3 ArrayList (java.util.ArrayList)2 FileVersionComparison (org.syncany.database.FileVersionComparator.FileVersionComparison)2 Test (org.junit.Test)1 FileVersion (org.syncany.database.FileVersion)1 FileSystemActionComparator (org.syncany.operations.down.FileSystemActionComparator)1