@Test
  public void testCreateRepositoryFromExistingRepositoryId() throws Exception {

    DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());

    RepositoryFactoryUtil.create(dlFolder.getRepositoryId());
  }
  @Test
  public void testCreateRepositoryFromNonexistentRepositoryId() throws Exception {

    long repositoryId = RandomTestUtil.randomLong();

    RepositoryFactoryUtil.create(repositoryId);
  }
  @Test(expected = NoSuchRepositoryEntryException.class)
  public void testCreateRepositoryFromNonexistentFileVersionId() throws Exception {

    long fileVersionId = RandomTestUtil.randomLong();

    RepositoryFactoryUtil.create(0, 0, fileVersionId);
  }
  @Test
  public void testCreateRepositoryFromExistingFileEntryId() throws Exception {
    DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());

    DLFileEntry dlFileEntry = DLTestUtil.addDLFileEntry(dlFolder.getFolderId());

    RepositoryFactoryUtil.create(0, dlFileEntry.getFileEntryId(), 0);
  }
  @Test(expected = PrincipalException.class)
  public void testCreateRepositoryFromExistingFolderWithoutPermissions() throws Exception {

    DLFolder dlFolder = DLTestUtil.addDLFolder(_group.getGroupId());

    PermissionChecker originalPermissionChecker = PermissionThreadLocal.getPermissionChecker();

    try {
      PermissionThreadLocal.setPermissionChecker(new AlwaysDenyingPermissionChecker());

      RepositoryFactoryUtil.create(dlFolder.getFolderId(), 0, 0);
    } finally {
      PermissionThreadLocal.setPermissionChecker(originalPermissionChecker);
    }
  }