コード例 #1
0
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    Release newRelease = _persistence.create(pk);

    newRelease.setMvccVersion(ServiceTestUtil.nextLong());

    newRelease.setCreateDate(ServiceTestUtil.nextDate());

    newRelease.setModifiedDate(ServiceTestUtil.nextDate());

    newRelease.setServletContextName(ServiceTestUtil.randomString());

    newRelease.setBuildNumber(ServiceTestUtil.nextInt());

    newRelease.setBuildDate(ServiceTestUtil.nextDate());

    newRelease.setVerified(ServiceTestUtil.randomBoolean());

    newRelease.setState(ServiceTestUtil.nextInt());

    newRelease.setTestString(ServiceTestUtil.randomString());

    _persistence.update(newRelease);

    Release existingRelease = _persistence.findByPrimaryKey(newRelease.getPrimaryKey());

    Assert.assertEquals(existingRelease.getMvccVersion(), newRelease.getMvccVersion());
    Assert.assertEquals(existingRelease.getReleaseId(), newRelease.getReleaseId());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getCreateDate()),
        Time.getShortTimestamp(newRelease.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getModifiedDate()),
        Time.getShortTimestamp(newRelease.getModifiedDate()));
    Assert.assertEquals(
        existingRelease.getServletContextName(), newRelease.getServletContextName());
    Assert.assertEquals(existingRelease.getBuildNumber(), newRelease.getBuildNumber());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getBuildDate()),
        Time.getShortTimestamp(newRelease.getBuildDate()));
    Assert.assertEquals(existingRelease.getVerified(), newRelease.getVerified());
    Assert.assertEquals(existingRelease.getState(), newRelease.getState());
    Assert.assertEquals(existingRelease.getTestString(), newRelease.getTestString());
  }
コード例 #2
0
  protected Release toUnwrappedModel(Release release) {
    if (release instanceof ReleaseImpl) {
      return release;
    }

    ReleaseImpl releaseImpl = new ReleaseImpl();

    releaseImpl.setNew(release.isNew());
    releaseImpl.setPrimaryKey(release.getPrimaryKey());

    releaseImpl.setReleaseId(release.getReleaseId());
    releaseImpl.setCreateDate(release.getCreateDate());
    releaseImpl.setModifiedDate(release.getModifiedDate());
    releaseImpl.setServletContextName(release.getServletContextName());
    releaseImpl.setBuildNumber(release.getBuildNumber());
    releaseImpl.setBuildDate(release.getBuildDate());
    releaseImpl.setVerified(release.isVerified());
    releaseImpl.setState(release.getState());
    releaseImpl.setTestString(release.getTestString());

    return releaseImpl;
  }