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

    PasswordTracker newPasswordTracker = _persistence.create(pk);

    newPasswordTracker.setMvccVersion(RandomTestUtil.nextLong());

    newPasswordTracker.setCompanyId(RandomTestUtil.nextLong());

    newPasswordTracker.setUserId(RandomTestUtil.nextLong());

    newPasswordTracker.setCreateDate(RandomTestUtil.nextDate());

    newPasswordTracker.setPassword(RandomTestUtil.randomString());

    _passwordTrackers.add(_persistence.update(newPasswordTracker));

    PasswordTracker existingPasswordTracker =
        _persistence.findByPrimaryKey(newPasswordTracker.getPrimaryKey());

    Assert.assertEquals(
        existingPasswordTracker.getMvccVersion(), newPasswordTracker.getMvccVersion());
    Assert.assertEquals(
        existingPasswordTracker.getPasswordTrackerId(), newPasswordTracker.getPasswordTrackerId());
    Assert.assertEquals(existingPasswordTracker.getCompanyId(), newPasswordTracker.getCompanyId());
    Assert.assertEquals(existingPasswordTracker.getUserId(), newPasswordTracker.getUserId());
    Assert.assertEquals(
        Time.getShortTimestamp(existingPasswordTracker.getCreateDate()),
        Time.getShortTimestamp(newPasswordTracker.getCreateDate()));
    Assert.assertEquals(existingPasswordTracker.getPassword(), newPasswordTracker.getPassword());
  }
Exemplo n.º 2
0
  protected PasswordTracker toUnwrappedModel(PasswordTracker passwordTracker) {
    if (passwordTracker instanceof PasswordTrackerImpl) {
      return passwordTracker;
    }

    PasswordTrackerImpl passwordTrackerImpl = new PasswordTrackerImpl();

    passwordTrackerImpl.setNew(passwordTracker.isNew());
    passwordTrackerImpl.setPrimaryKey(passwordTracker.getPrimaryKey());

    passwordTrackerImpl.setPasswordTrackerId(passwordTracker.getPasswordTrackerId());
    passwordTrackerImpl.setUserId(passwordTracker.getUserId());
    passwordTrackerImpl.setCreateDate(passwordTracker.getCreateDate());
    passwordTrackerImpl.setPassword(passwordTracker.getPassword());

    return passwordTrackerImpl;
  }