@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } PasswordPolicy newPasswordPolicy = addPasswordPolicy(); _persistence.clearCache(); PasswordPolicyModelImpl existingPasswordPolicyModelImpl = (PasswordPolicyModelImpl) _persistence.findByPrimaryKey(newPasswordPolicy.getPrimaryKey()); Assert.assertEquals( existingPasswordPolicyModelImpl.getCompanyId(), existingPasswordPolicyModelImpl.getOriginalCompanyId()); Assert.assertEquals( existingPasswordPolicyModelImpl.getDefaultPolicy(), existingPasswordPolicyModelImpl.getOriginalDefaultPolicy()); Assert.assertEquals( existingPasswordPolicyModelImpl.getCompanyId(), existingPasswordPolicyModelImpl.getOriginalCompanyId()); Assert.assertTrue( Validator.equals( existingPasswordPolicyModelImpl.getName(), existingPasswordPolicyModelImpl.getOriginalName())); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { PasswordPolicy newPasswordPolicy = addPasswordPolicy(); PasswordPolicy existingPasswordPolicy = _persistence.fetchByPrimaryKey(newPasswordPolicy.getPrimaryKey()); Assert.assertEquals(existingPasswordPolicy, newPasswordPolicy); }
@Test public void testCreate() throws Exception { long pk = ServiceTestUtil.nextLong(); PasswordPolicy passwordPolicy = _persistence.create(pk); Assert.assertNotNull(passwordPolicy); Assert.assertEquals(passwordPolicy.getPrimaryKey(), pk); }
@Test public void testRemove() throws Exception { PasswordPolicy newPasswordPolicy = addPasswordPolicy(); _persistence.remove(newPasswordPolicy); PasswordPolicy existingPasswordPolicy = _persistence.fetchByPrimaryKey(newPasswordPolicy.getPrimaryKey()); Assert.assertNull(existingPasswordPolicy); }
@Override public int compareTo(PasswordPolicy passwordPolicy) { long primaryKey = passwordPolicy.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof PasswordPolicy)) { return false; } PasswordPolicy passwordPolicy = (PasswordPolicy) obj; long primaryKey = passwordPolicy.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); PasswordPolicy newPasswordPolicy = _persistence.create(pk); newPasswordPolicy.setCompanyId(ServiceTestUtil.nextLong()); newPasswordPolicy.setUserId(ServiceTestUtil.nextLong()); newPasswordPolicy.setUserName(ServiceTestUtil.randomString()); newPasswordPolicy.setCreateDate(ServiceTestUtil.nextDate()); newPasswordPolicy.setModifiedDate(ServiceTestUtil.nextDate()); newPasswordPolicy.setDefaultPolicy(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setName(ServiceTestUtil.randomString()); newPasswordPolicy.setDescription(ServiceTestUtil.randomString()); newPasswordPolicy.setChangeable(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setChangeRequired(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setMinAge(ServiceTestUtil.nextLong()); newPasswordPolicy.setCheckSyntax(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setAllowDictionaryWords(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setMinAlphanumeric(ServiceTestUtil.nextInt()); newPasswordPolicy.setMinLength(ServiceTestUtil.nextInt()); newPasswordPolicy.setMinLowerCase(ServiceTestUtil.nextInt()); newPasswordPolicy.setMinNumbers(ServiceTestUtil.nextInt()); newPasswordPolicy.setMinSymbols(ServiceTestUtil.nextInt()); newPasswordPolicy.setMinUpperCase(ServiceTestUtil.nextInt()); newPasswordPolicy.setHistory(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setHistoryCount(ServiceTestUtil.nextInt()); newPasswordPolicy.setExpireable(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setMaxAge(ServiceTestUtil.nextLong()); newPasswordPolicy.setWarningTime(ServiceTestUtil.nextLong()); newPasswordPolicy.setGraceLimit(ServiceTestUtil.nextInt()); newPasswordPolicy.setLockout(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setMaxFailure(ServiceTestUtil.nextInt()); newPasswordPolicy.setLockoutDuration(ServiceTestUtil.nextLong()); newPasswordPolicy.setRequireUnlock(ServiceTestUtil.randomBoolean()); newPasswordPolicy.setResetFailureCount(ServiceTestUtil.nextLong()); newPasswordPolicy.setResetTicketMaxAge(ServiceTestUtil.nextLong()); _persistence.update(newPasswordPolicy, false); PasswordPolicy existingPasswordPolicy = _persistence.findByPrimaryKey(newPasswordPolicy.getPrimaryKey()); Assert.assertEquals( existingPasswordPolicy.getPasswordPolicyId(), newPasswordPolicy.getPasswordPolicyId()); Assert.assertEquals(existingPasswordPolicy.getCompanyId(), newPasswordPolicy.getCompanyId()); Assert.assertEquals(existingPasswordPolicy.getUserId(), newPasswordPolicy.getUserId()); Assert.assertEquals(existingPasswordPolicy.getUserName(), newPasswordPolicy.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingPasswordPolicy.getCreateDate()), Time.getShortTimestamp(newPasswordPolicy.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingPasswordPolicy.getModifiedDate()), Time.getShortTimestamp(newPasswordPolicy.getModifiedDate())); Assert.assertEquals( existingPasswordPolicy.getDefaultPolicy(), newPasswordPolicy.getDefaultPolicy()); Assert.assertEquals(existingPasswordPolicy.getName(), newPasswordPolicy.getName()); Assert.assertEquals( existingPasswordPolicy.getDescription(), newPasswordPolicy.getDescription()); Assert.assertEquals(existingPasswordPolicy.getChangeable(), newPasswordPolicy.getChangeable()); Assert.assertEquals( existingPasswordPolicy.getChangeRequired(), newPasswordPolicy.getChangeRequired()); Assert.assertEquals(existingPasswordPolicy.getMinAge(), newPasswordPolicy.getMinAge()); Assert.assertEquals( existingPasswordPolicy.getCheckSyntax(), newPasswordPolicy.getCheckSyntax()); Assert.assertEquals( existingPasswordPolicy.getAllowDictionaryWords(), newPasswordPolicy.getAllowDictionaryWords()); Assert.assertEquals( existingPasswordPolicy.getMinAlphanumeric(), newPasswordPolicy.getMinAlphanumeric()); Assert.assertEquals(existingPasswordPolicy.getMinLength(), newPasswordPolicy.getMinLength()); Assert.assertEquals( existingPasswordPolicy.getMinLowerCase(), newPasswordPolicy.getMinLowerCase()); Assert.assertEquals(existingPasswordPolicy.getMinNumbers(), newPasswordPolicy.getMinNumbers()); Assert.assertEquals(existingPasswordPolicy.getMinSymbols(), newPasswordPolicy.getMinSymbols()); Assert.assertEquals( existingPasswordPolicy.getMinUpperCase(), newPasswordPolicy.getMinUpperCase()); Assert.assertEquals(existingPasswordPolicy.getHistory(), newPasswordPolicy.getHistory()); Assert.assertEquals( existingPasswordPolicy.getHistoryCount(), newPasswordPolicy.getHistoryCount()); Assert.assertEquals(existingPasswordPolicy.getExpireable(), newPasswordPolicy.getExpireable()); Assert.assertEquals(existingPasswordPolicy.getMaxAge(), newPasswordPolicy.getMaxAge()); Assert.assertEquals( existingPasswordPolicy.getWarningTime(), newPasswordPolicy.getWarningTime()); Assert.assertEquals(existingPasswordPolicy.getGraceLimit(), newPasswordPolicy.getGraceLimit()); Assert.assertEquals(existingPasswordPolicy.getLockout(), newPasswordPolicy.getLockout()); Assert.assertEquals(existingPasswordPolicy.getMaxFailure(), newPasswordPolicy.getMaxFailure()); Assert.assertEquals( existingPasswordPolicy.getLockoutDuration(), newPasswordPolicy.getLockoutDuration()); Assert.assertEquals( existingPasswordPolicy.getRequireUnlock(), newPasswordPolicy.getRequireUnlock()); Assert.assertEquals( existingPasswordPolicy.getResetFailureCount(), newPasswordPolicy.getResetFailureCount()); Assert.assertEquals( existingPasswordPolicy.getResetTicketMaxAge(), newPasswordPolicy.getResetTicketMaxAge()); }