@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); SocialActivityAchievement newSocialActivityAchievement = _persistence.create(pk); newSocialActivityAchievement.setGroupId(ServiceTestUtil.nextLong()); newSocialActivityAchievement.setCompanyId(ServiceTestUtil.nextLong()); newSocialActivityAchievement.setUserId(ServiceTestUtil.nextLong()); newSocialActivityAchievement.setCreateDate(ServiceTestUtil.nextLong()); newSocialActivityAchievement.setName(ServiceTestUtil.randomString()); newSocialActivityAchievement.setFirstInGroup(ServiceTestUtil.randomBoolean()); _persistence.update(newSocialActivityAchievement); SocialActivityAchievement existingSocialActivityAchievement = _persistence.findByPrimaryKey(newSocialActivityAchievement.getPrimaryKey()); Assert.assertEquals( existingSocialActivityAchievement.getActivityAchievementId(), newSocialActivityAchievement.getActivityAchievementId()); Assert.assertEquals( existingSocialActivityAchievement.getGroupId(), newSocialActivityAchievement.getGroupId()); Assert.assertEquals( existingSocialActivityAchievement.getCompanyId(), newSocialActivityAchievement.getCompanyId()); Assert.assertEquals( existingSocialActivityAchievement.getUserId(), newSocialActivityAchievement.getUserId()); Assert.assertEquals( existingSocialActivityAchievement.getCreateDate(), newSocialActivityAchievement.getCreateDate()); Assert.assertEquals( existingSocialActivityAchievement.getName(), newSocialActivityAchievement.getName()); Assert.assertEquals( existingSocialActivityAchievement.getFirstInGroup(), newSocialActivityAchievement.getFirstInGroup()); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { SocialActivityAchievement newSocialActivityAchievement = addSocialActivityAchievement(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( SocialActivityAchievement.class, SocialActivityAchievement.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq( "activityAchievementId", newSocialActivityAchievement.getActivityAchievementId())); List<SocialActivityAchievement> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); SocialActivityAchievement existingSocialActivityAchievement = result.get(0); Assert.assertEquals(existingSocialActivityAchievement, newSocialActivityAchievement); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { SocialActivityAchievement newSocialActivityAchievement = addSocialActivityAchievement(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( SocialActivityAchievement.class, SocialActivityAchievement.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("activityAchievementId")); Object newActivityAchievementId = newSocialActivityAchievement.getActivityAchievementId(); dynamicQuery.add( RestrictionsFactoryUtil.in( "activityAchievementId", new Object[] {newActivityAchievementId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingActivityAchievementId = result.get(0); Assert.assertEquals(existingActivityAchievementId, newActivityAchievementId); }