@Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    WikiNode newWikiNode = addWikiNode();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWikiNode.getPrimaryKey());

    Map<Serializable, WikiNode> wikiNodes = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, wikiNodes.size());
    Assert.assertEquals(newWikiNode, wikiNodes.get(newWikiNode.getPrimaryKey()));
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
      return;
    }

    WikiNode newWikiNode = addWikiNode();

    _persistence.clearCache();

    WikiNodeModelImpl existingWikiNodeModelImpl =
        (WikiNodeModelImpl) _persistence.findByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertTrue(
        Validator.equals(
            existingWikiNodeModelImpl.getUuid(), existingWikiNodeModelImpl.getOriginalUuid()));
    Assert.assertEquals(
        existingWikiNodeModelImpl.getGroupId(), existingWikiNodeModelImpl.getOriginalGroupId());

    Assert.assertEquals(
        existingWikiNodeModelImpl.getGroupId(), existingWikiNodeModelImpl.getOriginalGroupId());
    Assert.assertTrue(
        Validator.equals(
            existingWikiNodeModelImpl.getName(), existingWikiNodeModelImpl.getOriginalName()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    WikiNode newWikiNode = addWikiNode();

    long pk = RandomTestUtil.nextLong();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWikiNode.getPrimaryKey());
    primaryKeys.add(pk);

    Map<Serializable, WikiNode> wikiNodes = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, wikiNodes.size());
    Assert.assertEquals(newWikiNode, wikiNodes.get(newWikiNode.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    WikiNode newWikiNode1 = addWikiNode();
    WikiNode newWikiNode2 = addWikiNode();

    Set<Serializable> primaryKeys = new HashSet<Serializable>();

    primaryKeys.add(newWikiNode1.getPrimaryKey());
    primaryKeys.add(newWikiNode2.getPrimaryKey());

    Map<Serializable, WikiNode> wikiNodes = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, wikiNodes.size());
    Assert.assertEquals(newWikiNode1, wikiNodes.get(newWikiNode1.getPrimaryKey()));
    Assert.assertEquals(newWikiNode2, wikiNodes.get(newWikiNode2.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    WikiNode newWikiNode = addWikiNode();

    WikiNode existingWikiNode = _persistence.fetchByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertEquals(existingWikiNode, newWikiNode);
  }
  @Test
  public void testCreate() throws Exception {
    long pk = RandomTestUtil.nextLong();

    WikiNode wikiNode = _persistence.create(pk);

    Assert.assertNotNull(wikiNode);

    Assert.assertEquals(wikiNode.getPrimaryKey(), pk);
  }
  @Test
  public void testRemove() throws Exception {
    WikiNode newWikiNode = addWikiNode();

    _persistence.remove(newWikiNode);

    WikiNode existingWikiNode = _persistence.fetchByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertNull(existingWikiNode);
  }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    WikiNode newWikiNode = _persistence.create(pk);

    newWikiNode.setUuid(RandomTestUtil.randomString());

    newWikiNode.setGroupId(RandomTestUtil.nextLong());

    newWikiNode.setCompanyId(RandomTestUtil.nextLong());

    newWikiNode.setUserId(RandomTestUtil.nextLong());

    newWikiNode.setUserName(RandomTestUtil.randomString());

    newWikiNode.setCreateDate(RandomTestUtil.nextDate());

    newWikiNode.setModifiedDate(RandomTestUtil.nextDate());

    newWikiNode.setName(RandomTestUtil.randomString());

    newWikiNode.setDescription(RandomTestUtil.randomString());

    newWikiNode.setLastPostDate(RandomTestUtil.nextDate());

    newWikiNode.setStatus(RandomTestUtil.nextInt());

    newWikiNode.setStatusByUserId(RandomTestUtil.nextLong());

    newWikiNode.setStatusByUserName(RandomTestUtil.randomString());

    newWikiNode.setStatusDate(RandomTestUtil.nextDate());

    _persistence.update(newWikiNode);

    WikiNode existingWikiNode = _persistence.findByPrimaryKey(newWikiNode.getPrimaryKey());

    Assert.assertEquals(existingWikiNode.getUuid(), newWikiNode.getUuid());
    Assert.assertEquals(existingWikiNode.getNodeId(), newWikiNode.getNodeId());
    Assert.assertEquals(existingWikiNode.getGroupId(), newWikiNode.getGroupId());
    Assert.assertEquals(existingWikiNode.getCompanyId(), newWikiNode.getCompanyId());
    Assert.assertEquals(existingWikiNode.getUserId(), newWikiNode.getUserId());
    Assert.assertEquals(existingWikiNode.getUserName(), newWikiNode.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getCreateDate()),
        Time.getShortTimestamp(newWikiNode.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getModifiedDate()),
        Time.getShortTimestamp(newWikiNode.getModifiedDate()));
    Assert.assertEquals(existingWikiNode.getName(), newWikiNode.getName());
    Assert.assertEquals(existingWikiNode.getDescription(), newWikiNode.getDescription());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getLastPostDate()),
        Time.getShortTimestamp(newWikiNode.getLastPostDate()));
    Assert.assertEquals(existingWikiNode.getStatus(), newWikiNode.getStatus());
    Assert.assertEquals(existingWikiNode.getStatusByUserId(), newWikiNode.getStatusByUserId());
    Assert.assertEquals(existingWikiNode.getStatusByUserName(), newWikiNode.getStatusByUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingWikiNode.getStatusDate()),
        Time.getShortTimestamp(newWikiNode.getStatusDate()));
  }