@Test public void testResetOriginalValues() throws Exception { if (!PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) { return; } PollsVote newPollsVote = addPollsVote(); _persistence.clearCache(); PollsVoteModelImpl existingPollsVoteModelImpl = (PollsVoteModelImpl) _persistence.findByPrimaryKey(newPollsVote.getPrimaryKey()); Assert.assertTrue( Validator.equals( existingPollsVoteModelImpl.getUuid(), existingPollsVoteModelImpl.getOriginalUuid())); Assert.assertEquals( existingPollsVoteModelImpl.getGroupId(), existingPollsVoteModelImpl.getOriginalGroupId()); Assert.assertEquals( existingPollsVoteModelImpl.getQuestionId(), existingPollsVoteModelImpl.getOriginalQuestionId()); Assert.assertEquals( existingPollsVoteModelImpl.getUserId(), existingPollsVoteModelImpl.getOriginalUserId()); }
@Test public void testFetchByPrimaryKeyExisting() throws Exception { PollsVote newPollsVote = addPollsVote(); PollsVote existingPollsVote = _persistence.fetchByPrimaryKey(newPollsVote.getPrimaryKey()); Assert.assertEquals(existingPollsVote, newPollsVote); }
@Test public void testRemove() throws Exception { PollsVote newPollsVote = addPollsVote(); _persistence.remove(newPollsVote); PollsVote existingPollsVote = _persistence.fetchByPrimaryKey(newPollsVote.getPrimaryKey()); Assert.assertNull(existingPollsVote); }
@Test public void testCreate() throws Exception { long pk = ServiceTestUtil.nextLong(); PollsVote pollsVote = _persistence.create(pk); Assert.assertNotNull(pollsVote); Assert.assertEquals(pollsVote.getPrimaryKey(), pk); }
@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); PollsVote newPollsVote = _persistence.create(pk); newPollsVote.setUuid(ServiceTestUtil.randomString()); newPollsVote.setGroupId(ServiceTestUtil.nextLong()); newPollsVote.setCompanyId(ServiceTestUtil.nextLong()); newPollsVote.setUserId(ServiceTestUtil.nextLong()); newPollsVote.setUserName(ServiceTestUtil.randomString()); newPollsVote.setCreateDate(ServiceTestUtil.nextDate()); newPollsVote.setModifiedDate(ServiceTestUtil.nextDate()); newPollsVote.setQuestionId(ServiceTestUtil.nextLong()); newPollsVote.setChoiceId(ServiceTestUtil.nextLong()); newPollsVote.setVoteDate(ServiceTestUtil.nextDate()); _persistence.update(newPollsVote); PollsVote existingPollsVote = _persistence.findByPrimaryKey(newPollsVote.getPrimaryKey()); Assert.assertEquals(existingPollsVote.getUuid(), newPollsVote.getUuid()); Assert.assertEquals(existingPollsVote.getVoteId(), newPollsVote.getVoteId()); Assert.assertEquals(existingPollsVote.getGroupId(), newPollsVote.getGroupId()); Assert.assertEquals(existingPollsVote.getCompanyId(), newPollsVote.getCompanyId()); Assert.assertEquals(existingPollsVote.getUserId(), newPollsVote.getUserId()); Assert.assertEquals(existingPollsVote.getUserName(), newPollsVote.getUserName()); Assert.assertEquals( Time.getShortTimestamp(existingPollsVote.getCreateDate()), Time.getShortTimestamp(newPollsVote.getCreateDate())); Assert.assertEquals( Time.getShortTimestamp(existingPollsVote.getModifiedDate()), Time.getShortTimestamp(newPollsVote.getModifiedDate())); Assert.assertEquals(existingPollsVote.getQuestionId(), newPollsVote.getQuestionId()); Assert.assertEquals(existingPollsVote.getChoiceId(), newPollsVote.getChoiceId()); Assert.assertEquals( Time.getShortTimestamp(existingPollsVote.getVoteDate()), Time.getShortTimestamp(newPollsVote.getVoteDate())); }