public void testUpdateExisting() throws Exception {
    long pk = nextLong();

    BookmarksFolder newBookmarksFolder = _persistence.create(pk);

    newBookmarksFolder.setUuid(randomString());

    newBookmarksFolder.setGroupId(nextLong());

    newBookmarksFolder.setCompanyId(nextLong());

    newBookmarksFolder.setUserId(nextLong());

    newBookmarksFolder.setUserName(randomString());

    newBookmarksFolder.setCreateDate(nextDate());

    newBookmarksFolder.setModifiedDate(nextDate());

    newBookmarksFolder.setParentFolderId(nextLong());

    newBookmarksFolder.setName(randomString());

    newBookmarksFolder.setDescription(randomString());

    _persistence.update(newBookmarksFolder, false);

    BookmarksFolder existingBookmarksFolder =
        _persistence.findByPrimaryKey(newBookmarksFolder.getPrimaryKey());

    assertEquals(existingBookmarksFolder.getUuid(), newBookmarksFolder.getUuid());
    assertEquals(existingBookmarksFolder.getFolderId(), newBookmarksFolder.getFolderId());
    assertEquals(existingBookmarksFolder.getGroupId(), newBookmarksFolder.getGroupId());
    assertEquals(existingBookmarksFolder.getCompanyId(), newBookmarksFolder.getCompanyId());
    assertEquals(existingBookmarksFolder.getUserId(), newBookmarksFolder.getUserId());
    assertEquals(existingBookmarksFolder.getUserName(), newBookmarksFolder.getUserName());
    assertEquals(
        Time.getShortTimestamp(existingBookmarksFolder.getCreateDate()),
        Time.getShortTimestamp(newBookmarksFolder.getCreateDate()));
    assertEquals(
        Time.getShortTimestamp(existingBookmarksFolder.getModifiedDate()),
        Time.getShortTimestamp(newBookmarksFolder.getModifiedDate()));
    assertEquals(
        existingBookmarksFolder.getParentFolderId(), newBookmarksFolder.getParentFolderId());
    assertEquals(existingBookmarksFolder.getName(), newBookmarksFolder.getName());
    assertEquals(existingBookmarksFolder.getDescription(), newBookmarksFolder.getDescription());
  }
  private static boolean _hasPermission(
      PermissionChecker permissionChecker, BookmarksFolder folder, String actionId) {

    if (permissionChecker.hasOwnerPermission(
            folder.getCompanyId(),
            BookmarksFolder.class.getName(),
            folder.getFolderId(),
            folder.getUserId(),
            actionId)
        || permissionChecker.hasPermission(
            folder.getGroupId(), BookmarksFolder.class.getName(), folder.getFolderId(), actionId)) {

      return true;
    }

    return false;
  }