Package org.hive2hive.core.model

Examples of org.hive2hive.core.model.UserProfile


    File file = new File(folder, NetworkTestUtil.randomString());
    FileUtils.writeStringToFile(file, NetworkTestUtil.randomString());
    UseCaseTestUtil.uploadNewFile(client, file);

    // store some things to be able to test later
    UserProfile userProfileBeforeDeletion = UseCaseTestUtil.getUserProfile(client, userCredentials);
    KeyPair metaKeyPairFolder = userProfileBeforeDeletion.getFileByPath(folder, root).getFileKeys();
    KeyPair metaKeyPairFile = userProfileBeforeDeletion.getFileByPath(file, root).getFileKeys();
    MetaFileSmall metaFileBeforeDeletion = (MetaFileSmall) UseCaseTestUtil.getMetaFile(client,
        metaKeyPairFile);
    Assert.assertNotNull(metaFileBeforeDeletion);

    // delete the file
    UseCaseTestUtil.deleteFile(client, file);

    // check if the file is still in the DHT
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNull(userProfile.getFileById(metaKeyPairFile.getPublic()));

    // check if the folder is still in the DHT
    Assert.assertNotNull(userProfile.getFileById(metaKeyPairFolder.getPublic()));

    // check the meta file is still in the DHT
    MetaFile metaFile = UseCaseTestUtil.getMetaFile(client, metaKeyPairFile, false);
    Assert.assertNull(metaFile);
  }
View Full Code Here


    File innerFolder = new File(folder, "inner-folder");
    innerFolder.mkdir();
    UseCaseTestUtil.uploadNewFile(client, innerFolder);

    // store some things to be able to test later
    UserProfile userProfileBeforeDeletion = UseCaseTestUtil.getUserProfile(client, userCredentials);
    KeyPair metaKeyPairFolder = userProfileBeforeDeletion.getFileByPath(folder, root).getFileKeys();
    KeyPair metaKeyPairInnerFolder = userProfileBeforeDeletion.getFileByPath(innerFolder, root)
        .getFileKeys();

    // delete the inner folder
    UseCaseTestUtil.deleteFile(client, innerFolder);

    // check if the inner folder is still in the DHT
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Assert.assertNull(userProfile.getFileById(metaKeyPairInnerFolder.getPublic()));

    // check if the outer folder is still in the DHT
    Assert.assertNotNull(userProfile.getFileById(metaKeyPairFolder.getPublic()));
  }
View Full Code Here

    Assert.assertTrue(file4.exists()); // added file is now here
    file2 = new File(root1, "file 2");
    Assert.assertFalse(file2.exists()); // deleted file is not here

    /** verify if the local changes have been uploaded **/
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(network.get(0), userCredentials);
    // added file is here
    Assert.assertTrue(userProfile.getFileByPath(Paths.get("added-file")) != null);
    // deleted file is not in user profile
    Assert.assertTrue(userProfile.getFileByPath(Paths.get("file 1")) == null);
  }
View Full Code Here

    // modification of file 2 has been downloaded
    file2 = new File(root1, "file 2");
    Assert.assertEquals(file2Content, FileUtils.readFileToString(file2));

    /** verify if the local changes have been uploaded **/
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(network.get(1), userCredentials);
    FileIndex file1Node = (FileIndex) userProfile.getFileByPath(Paths.get("file 1"));
    // modifications have been uploaded
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(newMD5File1, file1Node.getMD5()));

    /** verify the file that has been modified remotely and locally **/
    FileIndex file3Node = (FileIndex) userProfile.getFileByPath(Paths.get("folder 1", "file 3"));
    Assert.assertTrue(H2HEncryptionUtil.compareMD5(newMD5File3, file3Node.getMD5()));
  }
View Full Code Here

    String fileName = NetworkTestUtil.randomString();
    uploadedFile = FileTestUtil.createFileRandomContent(fileName, 10, uploaderRoot, CHUNK_SIZE);
    testContent = FileUtils.readFileToString(uploadedFile); // store for later tests
    UseCaseTestUtil.uploadNewFile(uploader, uploadedFile);

    UserProfile up = UseCaseTestUtil.getUserProfile(uploader, userCredentials);
    fileNode = up.getRoot().getChildByName(fileName);

  }
View Full Code Here

    }
  }

  private static void checkIndex(File oldFileAtA, File oldFileAtB, File newFileAtA, File newFileAtB)
      throws GetFailedException, NoSessionException {
    UserProfile userProfileA = network.get(0).getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    Index oldIndexAtA = userProfileA.getFileByPath(rootA.toPath().relativize(oldFileAtA.toPath()));
    Index newIndexAtA = userProfileA.getFileByPath(rootA.toPath().relativize(newFileAtA.toPath()));

    UserProfile userProfileB = network.get(1).getSession().getProfileManager()
        .getUserProfile(UUID.randomUUID().toString(), false);
    Index oldIndexAtB = userProfileB.getFileByPath(rootB.toPath().relativize(oldFileAtB.toPath()));
    Index newIndexAtB = userProfileB.getFileByPath(rootB.toPath().relativize(newFileAtB.toPath()));

    // check if old indexes have been removed
    Assert.assertNull(oldIndexAtA);
    Assert.assertNull(oldIndexAtB);
View Full Code Here

    // assert that the file is moved
    Assert.assertTrue(destination.exists());

    // check that the user profile has a correct entry
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Index fileNode = userProfile.getFileByPath(destination, root.toPath());
    Assert.assertNotNull(fileNode);
    Assert.assertEquals(folder.getName(), fileNode.getParent().getName());
  }
View Full Code Here

    // assert that the file is moved
    Assert.assertTrue(destination.exists());

    // check that the user profile has a correct entry
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Index fileNode = userProfile.getFileByPath(destination, root.toPath());
    Assert.assertNotNull(fileNode);
    Assert.assertEquals(userProfile.getRoot(), fileNode.getParent());

    // root contains moved file and empty folder as file
    Assert.assertEquals(2, userProfile.getRoot().getChildren().size());
  }
View Full Code Here

    // assert that the file is moved
    Assert.assertTrue(destination.exists());

    // check that the user profile has a correct entry
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Index fileNode = userProfile.getFileByPath(destination, root.toPath());
    Assert.assertNotNull(fileNode);
    Assert.assertEquals(destFolder.getName(), fileNode.getParent().getName());
  }
View Full Code Here

    // assert that the file is moved
    Assert.assertTrue(destination.exists());

    // check that the user profile has a correct entry
    UserProfile userProfile = UseCaseTestUtil.getUserProfile(client, userCredentials);
    Index fileNode = userProfile.getFileByPath(destination, root.toPath());
    Assert.assertNotNull(fileNode);
    Assert.assertEquals(fileNode.getName(), destination.getName());
  }
View Full Code Here

TOP

Related Classes of org.hive2hive.core.model.UserProfile

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.