@Test
  public void testFetchByPrimaryKeysWithOnePrimaryKey() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

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

    primaryKeys.add(newRatingsEntry.getPrimaryKey());

    Map<Serializable, RatingsEntry> ratingsEntries = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, ratingsEntries.size());
    Assert.assertEquals(newRatingsEntry, ratingsEntries.get(newRatingsEntry.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereSomePrimaryKeysExist()
      throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

    long pk = RandomTestUtil.nextLong();

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

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

    Map<Serializable, RatingsEntry> ratingsEntries = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(1, ratingsEntries.size());
    Assert.assertEquals(newRatingsEntry, ratingsEntries.get(newRatingsEntry.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeysWithMultiplePrimaryKeysWhereAllPrimaryKeysExist()
      throws Exception {
    RatingsEntry newRatingsEntry1 = addRatingsEntry();
    RatingsEntry newRatingsEntry2 = addRatingsEntry();

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

    primaryKeys.add(newRatingsEntry1.getPrimaryKey());
    primaryKeys.add(newRatingsEntry2.getPrimaryKey());

    Map<Serializable, RatingsEntry> ratingsEntries = _persistence.fetchByPrimaryKeys(primaryKeys);

    Assert.assertEquals(2, ratingsEntries.size());
    Assert.assertEquals(newRatingsEntry1, ratingsEntries.get(newRatingsEntry1.getPrimaryKey()));
    Assert.assertEquals(newRatingsEntry2, ratingsEntries.get(newRatingsEntry2.getPrimaryKey()));
  }
  @Test
  public void testFetchByPrimaryKeyExisting() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

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

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

    RatingsEntry ratingsEntry = _persistence.create(pk);

    Assert.assertNotNull(ratingsEntry);

    Assert.assertEquals(ratingsEntry.getPrimaryKey(), pk);
  }
  @Test
  public void testRemove() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

    _persistence.remove(newRatingsEntry);

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

    Assert.assertNull(existingRatingsEntry);
  }
  @Override
  public int compareTo(RatingsEntry ratingsEntry) {
    long primaryKey = ratingsEntry.getPrimaryKey();

    if (getPrimaryKey() < primaryKey) {
      return -1;
    } else if (getPrimaryKey() > primaryKey) {
      return 1;
    } else {
      return 0;
    }
  }
  @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()));
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof RatingsEntry)) {
      return false;
    }

    RatingsEntry ratingsEntry = (RatingsEntry) obj;

    long primaryKey = ratingsEntry.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  @Test
  public void testResetOriginalValues() throws Exception {
    RatingsEntry newRatingsEntry = addRatingsEntry();

    _persistence.clearCache();

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

    Assert.assertEquals(
        Long.valueOf(existingRatingsEntry.getUserId()),
        ReflectionTestUtil.<Long>invoke(
            existingRatingsEntry, "getOriginalUserId", new Class<?>[0]));
    Assert.assertEquals(
        Long.valueOf(existingRatingsEntry.getClassNameId()),
        ReflectionTestUtil.<Long>invoke(
            existingRatingsEntry, "getOriginalClassNameId", new Class<?>[0]));
    Assert.assertEquals(
        Long.valueOf(existingRatingsEntry.getClassPK()),
        ReflectionTestUtil.<Long>invoke(
            existingRatingsEntry, "getOriginalClassPK", new Class<?>[0]));
  }