public void testFetchByPrimaryKeyExisting() throws Exception {
    BookmarksFolder newBookmarksFolder = addBookmarksFolder();

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

    assertEquals(existingBookmarksFolder, newBookmarksFolder);
  }
  public void testCreate() throws Exception {
    long pk = nextLong();

    BookmarksFolder bookmarksFolder = _persistence.create(pk);

    assertNotNull(bookmarksFolder);

    assertEquals(bookmarksFolder.getPrimaryKey(), pk);
  }
  public void testRemove() throws Exception {
    BookmarksFolder newBookmarksFolder = addBookmarksFolder();

    _persistence.remove(newBookmarksFolder);

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

    assertNull(existingBookmarksFolder);
  }
  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());
  }
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    BookmarksFolder newBookmarksFolder = addBookmarksFolder();

    _persistence.clearCache();

    BookmarksFolderModelImpl existingBookmarksFolderModelImpl =
        (BookmarksFolderModelImpl)
            _persistence.findByPrimaryKey(newBookmarksFolder.getPrimaryKey());

    assertTrue(
        Validator.equals(
            existingBookmarksFolderModelImpl.getUuid(),
            existingBookmarksFolderModelImpl.getOriginalUuid()));
    assertEquals(
        existingBookmarksFolderModelImpl.getGroupId(),
        existingBookmarksFolderModelImpl.getOriginalGroupId());
  }
예제 #6
0
  @Override
  public List<TrashRenderer> getTrashContainerModelTrashRenderers(long classPK, int start, int end)
      throws PortalException, SystemException {

    List<TrashRenderer> trashRenderers = new ArrayList<TrashRenderer>();

    BookmarksFolder folder = BookmarksFolderLocalServiceUtil.getFolder(classPK);

    List<BookmarksFolder> folders =
        BookmarksFolderLocalServiceUtil.getFolders(folder.getGroupId(), classPK, start, end);

    for (BookmarksFolder curFolder : folders) {
      TrashHandler trashHandler =
          TrashHandlerRegistryUtil.getTrashHandler(BookmarksFolder.class.getName());

      TrashRenderer trashRenderer = trashHandler.getTrashRenderer(curFolder.getPrimaryKey());

      trashRenderers.add(trashRenderer);
    }

    return trashRenderers;
  }