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

    RatingsEntry newRatingsEntry = _persistence.create(pk);

    newRatingsEntry.setUuid(RandomTestUtil.randomString());

    newRatingsEntry.setCompanyId(RandomTestUtil.nextLong());

    newRatingsEntry.setUserId(RandomTestUtil.nextLong());

    newRatingsEntry.setUserName(RandomTestUtil.randomString());

    newRatingsEntry.setCreateDate(RandomTestUtil.nextDate());

    newRatingsEntry.setModifiedDate(RandomTestUtil.nextDate());

    newRatingsEntry.setClassNameId(RandomTestUtil.nextLong());

    newRatingsEntry.setClassPK(RandomTestUtil.nextLong());

    newRatingsEntry.setScore(RandomTestUtil.nextDouble());

    newRatingsEntry.setLastPublishDate(RandomTestUtil.nextDate());

    _ratingsEntries.add(_persistence.update(newRatingsEntry));

    RatingsEntry existingRatingsEntry =
        _persistence.findByPrimaryKey(newRatingsEntry.getPrimaryKey());

    Assert.assertEquals(existingRatingsEntry.getUuid(), newRatingsEntry.getUuid());
    Assert.assertEquals(existingRatingsEntry.getEntryId(), newRatingsEntry.getEntryId());
    Assert.assertEquals(existingRatingsEntry.getCompanyId(), newRatingsEntry.getCompanyId());
    Assert.assertEquals(existingRatingsEntry.getUserId(), newRatingsEntry.getUserId());
    Assert.assertEquals(existingRatingsEntry.getUserName(), newRatingsEntry.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRatingsEntry.getCreateDate()),
        Time.getShortTimestamp(newRatingsEntry.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingRatingsEntry.getModifiedDate()),
        Time.getShortTimestamp(newRatingsEntry.getModifiedDate()));
    Assert.assertEquals(existingRatingsEntry.getClassNameId(), newRatingsEntry.getClassNameId());
    Assert.assertEquals(existingRatingsEntry.getClassPK(), newRatingsEntry.getClassPK());
    AssertUtils.assertEquals(existingRatingsEntry.getScore(), newRatingsEntry.getScore());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRatingsEntry.getLastPublishDate()),
        Time.getShortTimestamp(newRatingsEntry.getLastPublishDate()));
  }
  @Test
  public void testDynamicQueryByPrimaryKeyExisting() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(RatingsEntry.class, _dynamicQueryClassLoader);

    dynamicQuery.add(RestrictionsFactoryUtil.eq("entryId", newRatingsEntry.getEntryId()));

    List<RatingsEntry> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    RatingsEntry existingRatingsEntry = result.get(0);

    Assert.assertEquals(existingRatingsEntry, newRatingsEntry);
  }
  protected String getRatingsEntryPath(
      PortletDataContext portletDataContext,
      String className,
      String classPK,
      RatingsEntry ratingsEntry) {

    StringBundler sb = new StringBundler(8);

    sb.append(portletDataContext.getRootPath());
    sb.append("/ratings/");
    sb.append(PortalUtil.getClassNameId(className));
    sb.append(CharPool.FORWARD_SLASH);
    sb.append(classPK);
    sb.append(CharPool.FORWARD_SLASH);
    sb.append(ratingsEntry.getEntryId());
    sb.append(".xml");

    return sb.toString();
  }
  @Test
  public void testDynamicQueryByProjectionExisting() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

    DynamicQuery dynamicQuery =
        DynamicQueryFactoryUtil.forClass(RatingsEntry.class, _dynamicQueryClassLoader);

    dynamicQuery.setProjection(ProjectionFactoryUtil.property("entryId"));

    Object newEntryId = newRatingsEntry.getEntryId();

    dynamicQuery.add(RestrictionsFactoryUtil.in("entryId", new Object[] {newEntryId}));

    List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery);

    Assert.assertEquals(1, result.size());

    Object existingEntryId = result.get(0);

    Assert.assertEquals(existingEntryId, newEntryId);
  }