Search in sources :

Example 11 with FileSystemAction

use of org.syncany.operations.down.actions.FileSystemAction 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

FileSystemAction (org.syncany.operations.down.actions.FileSystemAction)11 DeleteFileSystemAction (org.syncany.operations.down.actions.DeleteFileSystemAction)9 NewFileSystemAction (org.syncany.operations.down.actions.NewFileSystemAction)9 RenameFileSystemAction (org.syncany.operations.down.actions.RenameFileSystemAction)9 ChangeFileSystemAction (org.syncany.operations.down.actions.ChangeFileSystemAction)5 NewSymlinkFileSystemAction (org.syncany.operations.down.actions.NewSymlinkFileSystemAction)5 SetAttributesFileSystemAction (org.syncany.operations.down.actions.SetAttributesFileSystemAction)5 ArrayList (java.util.ArrayList)3 FileVersionComparison (org.syncany.database.FileVersionComparator.FileVersionComparison)3 Test (org.junit.Test)2 FileVersion (org.syncany.database.FileVersion)2 PartialFileHistory (org.syncany.database.PartialFileHistory)2 File (java.io.File)1 Config (org.syncany.config.Config)1 DatabaseVersion (org.syncany.database.DatabaseVersion)1 MemoryDatabase (org.syncany.database.MemoryDatabase)1 FileHistoryId (org.syncany.database.PartialFileHistory.FileHistoryId)1 Assembler (org.syncany.operations.Assembler)1 DownOperationResult (org.syncany.operations.down.DownOperationResult)1 FileSystemActionComparator (org.syncany.operations.down.FileSystemActionComparator)1