Ejemplo n.º 1
0
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static Calendar toModel(CalendarSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    Calendar model = new CalendarImpl();

    model.setUuid(soapModel.getUuid());
    model.setCalendarId(soapModel.getCalendarId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setResourceBlockId(soapModel.getResourceBlockId());
    model.setCalendarResourceId(soapModel.getCalendarResourceId());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setColor(soapModel.getColor());
    model.setDefaultCalendar(soapModel.getDefaultCalendar());
    model.setEnableComments(soapModel.getEnableComments());
    model.setEnableRatings(soapModel.getEnableRatings());

    return model;
  }
  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()));
  }