Package org.syncany.database

Examples of org.syncany.database.FileVersion


    MemoryDatabase database = new MemoryDatabase();

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file1.jpg");
    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertEquals(fileHistory1, database.getFileHistory("file1.jpg"));

    // Round 2: Add new version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file2.jpg", fileVersion1);
    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    database.addDatabaseVersion(databaseVersion2);

    assertNotNull(database.getFileHistory("file2.jpg"));
    assertEquals(2, database.getFileHistory("file2.jpg").getFileVersions().size());
    assertNull(database.getFileHistory("file1.jpg"));

    // Round 3: Add deleted version
    DatabaseVersion databaseVersion3 = TestDatabaseUtil.createDatabaseVersion(databaseVersion2);

    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("file2.jpg", fileVersion2);
    fileVersion3.setStatus(FileStatus.DELETED);

    FileHistoryId idFile3 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // same ID

    fileHistory3.addFileVersion(fileVersion3);
View Full Code Here


    MemoryDatabase database = new MemoryDatabase();

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file1.jpg");
    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertEquals(fileHistory1, database.getFileHistory("file1.jpg"));

    // Round 2: Add new version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - delete file1.jpg
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file1.jpg", fileVersion1);
    fileVersion2.setStatus(FileStatus.DELETED);

    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    // - add file1.jpg (as FOLDER!)
    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("file1.jpg"); // new file!
    fileVersion3.setType(FileType.FOLDER);

    FileHistoryId idFile3 = FileHistoryId.parseFileId("1111111111111112"); // different ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // same ID

    fileHistory3.addFileVersion(fileVersion3);
View Full Code Here

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("samechecksum1.jpg");
    fileVersion1.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    assertNotNull(database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })));
    assertEquals(1, database.getFileHistories(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })).size());

    // Round 2: Add two other versions with same checksum to new database version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - history 1, version 2
    FileVersion fileVersion11 = TestDatabaseUtil.createFileVersion("samechecksum2-renamed.jpg", fileVersion1);
    fileVersion11.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
    fileVersion11.setStatus(FileStatus.RENAMED);

    FileHistoryId idFile11 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory11 = new PartialFileHistory(idFile11); // same ID as above

    fileHistory11.addFileVersion(fileVersion11);
    databaseVersion2.addFileHistory(fileHistory11);

    // - history 2, version 1
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("samechecksum2.jpg");
    fileVersion2.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!

    FileHistoryId idFile2 = FileHistoryId.parseFileId("1111111122222222"); // different ID
    PartialFileHistory fileHistory2 = new PartialFileHistory(idFile2);

    fileHistory2.addFileVersion(fileVersion2);
    databaseVersion2.addFileHistory(fileHistory2);

    // - history 3, version 1
    FileVersion fileVersion3 = TestDatabaseUtil.createFileVersion("samechecksum3.jpg");
    fileVersion3.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!

    FileHistoryId idFile3 = FileHistoryId.parseFileId("aaaaaaaa22222222"); // different ID
    PartialFileHistory fileHistory3 = new PartialFileHistory(idFile3); // different ID

    fileHistory3.addFileVersion(fileVersion3);
View Full Code Here

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("samechecksum1.jpg");
    fileVersion1.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }));

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);

    FileHistoryId idFile1Get = FileHistoryId.parseFileId("1111111111111111");
    assertNotNull(database.getFileHistory(idFile1Get));
    assertEquals(fileHistory1, database.getFileHistory(idFile1Get));

    // Round 2: Add two other versions with same checksum to new database version
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);

    // - history 1, version 2
    FileVersion fileVersion11 = TestDatabaseUtil.createFileVersion("samechecksum2-renamed.jpg", fileVersion1);
    fileVersion11.setChecksum(new FileChecksum(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 })); // same checksum!
    fileVersion11.setStatus(FileStatus.RENAMED);

    FileHistoryId idFile11 = FileHistoryId.parseFileId("1111111111111111"); // same ID
    PartialFileHistory fileHistory11 = new PartialFileHistory(idFile11);

    fileHistory11.addFileVersion(fileVersion11);
View Full Code Here

    // Round 1: Add file history & version
    DatabaseVersion databaseVersion1 = TestDatabaseUtil.createDatabaseVersion();

    // - history 1, version 1
    FileVersion fileVersion1 = TestDatabaseUtil.createFileVersion("file.jpg");

    FileHistoryId idFile1 = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1 = new PartialFileHistory(idFile1);

    fileHistory1.addFileVersion(fileVersion1);
    databaseVersion1.addFileHistory(fileHistory1);

    database.addDatabaseVersion(databaseVersion1);
   
    // - history 1, version 2   
    DatabaseVersion databaseVersion2 = TestDatabaseUtil.createDatabaseVersion(databaseVersion1);
    FileVersion fileVersion2 = TestDatabaseUtil.createFileVersion("file.jpg", fileVersion1);

    FileHistoryId idFile1b = FileHistoryId.parseFileId("1111111111111111");
    PartialFileHistory fileHistory1b = new PartialFileHistory(idFile1b);

    fileHistory1b.addFileVersion(fileVersion2);
View Full Code Here

    // Run
    TestSqlUtil.runSqlFromResource(databaseConnection, "test.insert.set1.sql");

    FileVersionSqlDao fileVersionDao = new FileVersionSqlDao(databaseConnection);       
   
    FileVersion file1ByPath = fileVersionDao.getFileVersionByPath("file1");
    FileVersion file2ByPath = fileVersionDao.getFileVersionByPath("file2");
    FileVersion file3ByPath = fileVersionDao.getFileVersionByPath("file3");
    FileVersion file4ByPath = fileVersionDao.getFileVersionByPath("file4");
   
    // Test
   
    // - By Path: File 1
    assertNotNull(file1ByPath);
View Full Code Here

    PartialFileHistory file1WithDiffLastModDate = clientDatabaseB.getFileHistoryWithFileVersions("A-file1-with-different-modified-date-moved.jpg");
   
    assertNotNull(file1Orig);
    assertNotNull(file1WithDiffLastModDate);
   
    FileVersion fileVersion1OrigV1 = file1Orig.getFileVersion(1);
    FileVersion fileVersion1OrigV2 = file1Orig.getFileVersion(2);
   
    FileVersion fileVersion1WithDiffLastModDateV1 = file1WithDiffLastModDate.getFileVersion(1);
    FileVersion fileVersion1WithDiffLastModDateV2 = file1WithDiffLastModDate.getFileVersion(2);
   
    assertNotNull(fileVersion1OrigV1);
    assertNotNull(fileVersion1OrigV2);
    assertNotNull(fileVersion1WithDiffLastModDateV1);
    assertNotNull(fileVersion1WithDiffLastModDateV2);
   
    assertEquals("A-file1.jpg", fileVersion1OrigV1.getName());
    assertEquals("A-file1-moved.jpg", fileVersion1OrigV2.getName());
    assertEquals("A-file1-with-different-modified-date.jpg", fileVersion1WithDiffLastModDateV1.getName());
    assertEquals("A-file1-with-different-modified-date-moved.jpg", fileVersion1WithDiffLastModDateV2.getName());
   
    // Tear down
    clientA.deleteTestData();
    clientB.deleteTestData();
  }
View Full Code Here

   
    System.out.println(actions);
  }
 
  private DeleteFileSystemAction createDeleteFileSystemAction(String path, FileType type) throws Exception {
    FileVersion firstFileVersion = createFileVersion(path, type);
    FileVersion secondFileVersion = createFileVersion(path, type, firstFileVersion);
   
    return new DeleteFileSystemAction(createDummyConfig(), firstFileVersion, secondFileVersion, null);
 
View Full Code Here

   
    return new DeleteFileSystemAction(createDummyConfig(), firstFileVersion, secondFileVersion, null);
 

  private NewFileSystemAction createNewFileSystemAction(String path, FileType type) throws Exception {
    FileVersion firstFileVersion = createFileVersion(path, type);
    return new NewFileSystemAction(createDummyConfig(), firstFileVersion, null);
  }
View Full Code Here

    FileVersion firstFileVersion = createFileVersion(path, type);
    return new NewFileSystemAction(createDummyConfig(), firstFileVersion, null);
  }
 
  private RenameFileSystemAction createRenameFileSystemAction(String fromPath, String toPath, FileType type) throws Exception {
    FileVersion firstFileVersion = createFileVersion(fromPath, type);
    FileVersion secondFileVersion = createFileVersion(toPath, type, firstFileVersion);
   
    return new RenameFileSystemAction(createDummyConfig(), firstFileVersion, secondFileVersion, null);
  }
View Full Code Here

TOP

Related Classes of org.syncany.database.FileVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.