コード例 #1
0
  @Test
  public void testDoUpdateFolderSyncFile() throws Exception {
    SyncFile folderSyncFileA =
        SyncFileTestUtil.addFolderSyncFile(
            FileUtil.getFilePathName(filePathName, "a"), syncAccount.getSyncAccountId());

    SyncFile folderSyncFileB =
        SyncFileTestUtil.addFolderSyncFile(
            FileUtil.getFilePathName(filePathName, "b"), syncAccount.getSyncAccountId());

    SyncFile folderSyncFileAA =
        SyncFileTestUtil.addFolderSyncFile(
            FileUtil.getFilePathName(filePathName, "a", "a"),
            folderSyncFileA.getTypePK(),
            syncAccount.getSyncAccountId());

    SyncFile fileSyncFileAA =
        SyncFileTestUtil.addFileSyncFile(
            FileUtil.getFilePathName(filePathName, "a", "a.txt"),
            folderSyncFileA.getTypePK(),
            syncAccount.getSyncAccountId());

    SyncFileService.updateSyncFile(
        Paths.get(FileUtil.getFilePathName(filePathName, "b", "a")),
        folderSyncFileB.getTypePK(),
        folderSyncFileA);

    SyncFilePersistence syncFilePersistence = SyncFileService.getSyncFilePersistence();

    folderSyncFileAA = syncFilePersistence.queryForId(folderSyncFileAA.getTypePK());

    Assert.assertEquals(
        FileUtil.getFilePathName(filePathName, "b", "a", "a"), folderSyncFileAA.getFilePathName());

    fileSyncFileAA = syncFilePersistence.queryForId(fileSyncFileAA.getTypePK());

    Assert.assertEquals(
        FileUtil.getFilePathName(filePathName, "b", "a", "a.txt"),
        fileSyncFileAA.getFilePathName());
  }
コード例 #2
0
  @Test
  public void testDeleteFolderSyncFile() throws Exception {
    List<SyncFile> syncFiles = SyncFileService.findSyncFiles(syncAccount.getSyncAccountId());

    Assert.assertEquals(1, syncFiles.size());

    SyncFile folderSyncFileA =
        SyncFileTestUtil.addFolderSyncFile(
            FileUtil.getFilePathName(filePathName, "a"), syncAccount.getSyncAccountId());

    SyncFile folderSyncFileAA =
        SyncFileTestUtil.addFolderSyncFile(
            FileUtil.getFilePathName(filePathName, "a", "a"),
            folderSyncFileA.getTypePK(),
            syncAccount.getSyncAccountId());

    SyncFileTestUtil.addFolderSyncFile(
        FileUtil.getFilePathName(filePathName, "a", "b"),
        folderSyncFileA.getTypePK(),
        syncAccount.getSyncAccountId());

    SyncFileTestUtil.addFolderSyncFile(
        FileUtil.getFilePathName(filePathName, "a", "a", "a"),
        folderSyncFileAA.getTypePK(),
        syncAccount.getSyncAccountId());

    SyncFileTestUtil.addFileSyncFile(
        FileUtil.getFilePathName(filePathName, "a", "b.txt"),
        folderSyncFileA.getTypePK(),
        syncAccount.getSyncAccountId());

    SyncFileTestUtil.addFileSyncFile(
        FileUtil.getFilePathName(filePathName, "a", "c.txt"),
        folderSyncFileA.getTypePK(),
        syncAccount.getSyncAccountId());

    SyncFileTestUtil.addFileSyncFile(
        FileUtil.getFilePathName(filePathName, "a", "a", "a.txt"),
        folderSyncFileAA.getTypePK(),
        syncAccount.getSyncAccountId());

    syncFiles = SyncFileService.findSyncFiles(syncAccount.getSyncAccountId());

    Assert.assertEquals(8, syncFiles.size());

    SyncFileService.deleteSyncFile(folderSyncFileA);

    syncFiles = SyncFileService.findSyncFiles(syncAccount.getSyncAccountId());

    Assert.assertEquals(1, syncFiles.size());
  }