protected Calendar addCalendar() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Calendar calendar = _persistence.create(pk);

    calendar.setUuid(RandomTestUtil.randomString());

    calendar.setGroupId(RandomTestUtil.nextLong());

    calendar.setCompanyId(RandomTestUtil.nextLong());

    calendar.setUserId(RandomTestUtil.nextLong());

    calendar.setUserName(RandomTestUtil.randomString());

    calendar.setCreateDate(RandomTestUtil.nextDate());

    calendar.setModifiedDate(RandomTestUtil.nextDate());

    calendar.setResourceBlockId(RandomTestUtil.nextLong());

    calendar.setCalendarResourceId(RandomTestUtil.nextLong());

    calendar.setName(RandomTestUtil.randomString());

    calendar.setDescription(RandomTestUtil.randomString());

    calendar.setTimeZoneId(RandomTestUtil.randomString());

    calendar.setColor(RandomTestUtil.nextInt());

    calendar.setDefaultCalendar(RandomTestUtil.randomBoolean());

    calendar.setEnableComments(RandomTestUtil.randomBoolean());

    calendar.setEnableRatings(RandomTestUtil.randomBoolean());

    calendar.setLastPublishDate(RandomTestUtil.nextDate());

    _calendars.add(_persistence.update(calendar));

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

    Calendar newCalendar = _persistence.create(pk);

    newCalendar.setUuid(RandomTestUtil.randomString());

    newCalendar.setGroupId(RandomTestUtil.nextLong());

    newCalendar.setCompanyId(RandomTestUtil.nextLong());

    newCalendar.setUserId(RandomTestUtil.nextLong());

    newCalendar.setUserName(RandomTestUtil.randomString());

    newCalendar.setCreateDate(RandomTestUtil.nextDate());

    newCalendar.setModifiedDate(RandomTestUtil.nextDate());

    newCalendar.setResourceBlockId(RandomTestUtil.nextLong());

    newCalendar.setCalendarResourceId(RandomTestUtil.nextLong());

    newCalendar.setName(RandomTestUtil.randomString());

    newCalendar.setDescription(RandomTestUtil.randomString());

    newCalendar.setTimeZoneId(RandomTestUtil.randomString());

    newCalendar.setColor(RandomTestUtil.nextInt());

    newCalendar.setDefaultCalendar(RandomTestUtil.randomBoolean());

    newCalendar.setEnableComments(RandomTestUtil.randomBoolean());

    newCalendar.setEnableRatings(RandomTestUtil.randomBoolean());

    newCalendar.setLastPublishDate(RandomTestUtil.nextDate());

    _calendars.add(_persistence.update(newCalendar));

    Calendar existingCalendar = _persistence.findByPrimaryKey(newCalendar.getPrimaryKey());

    Assert.assertEquals(existingCalendar.getUuid(), newCalendar.getUuid());
    Assert.assertEquals(existingCalendar.getCalendarId(), newCalendar.getCalendarId());
    Assert.assertEquals(existingCalendar.getGroupId(), newCalendar.getGroupId());
    Assert.assertEquals(existingCalendar.getCompanyId(), newCalendar.getCompanyId());
    Assert.assertEquals(existingCalendar.getUserId(), newCalendar.getUserId());
    Assert.assertEquals(existingCalendar.getUserName(), newCalendar.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getCreateDate()),
        Time.getShortTimestamp(newCalendar.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getModifiedDate()),
        Time.getShortTimestamp(newCalendar.getModifiedDate()));
    Assert.assertEquals(existingCalendar.getResourceBlockId(), newCalendar.getResourceBlockId());
    Assert.assertEquals(
        existingCalendar.getCalendarResourceId(), newCalendar.getCalendarResourceId());
    Assert.assertEquals(existingCalendar.getName(), newCalendar.getName());
    Assert.assertEquals(existingCalendar.getDescription(), newCalendar.getDescription());
    Assert.assertEquals(existingCalendar.getTimeZoneId(), newCalendar.getTimeZoneId());
    Assert.assertEquals(existingCalendar.getColor(), newCalendar.getColor());
    Assert.assertEquals(existingCalendar.getDefaultCalendar(), newCalendar.getDefaultCalendar());
    Assert.assertEquals(existingCalendar.getEnableComments(), newCalendar.getEnableComments());
    Assert.assertEquals(existingCalendar.getEnableRatings(), newCalendar.getEnableRatings());
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getLastPublishDate()),
        Time.getShortTimestamp(newCalendar.getLastPublishDate()));
  }