@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());
  }
  @Override
  public int compareTo(PasswordTracker passwordTracker) {
    int value = 0;

    if (getUserId() < passwordTracker.getUserId()) {
      value = -1;
    } else if (getUserId() > passwordTracker.getUserId()) {
      value = 1;
    } else {
      value = 0;
    }

    value = value * -1;

    if (value != 0) {
      return value;
    }

    value = DateUtil.compareTo(getCreateDate(), passwordTracker.getCreateDate());

    value = value * -1;

    if (value != 0) {
      return value;
    }

    return 0;
  }
Exemple #3
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;
  }