@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); AnnouncementsDelivery newAnnouncementsDelivery = _persistence.create(pk); newAnnouncementsDelivery.setCompanyId(ServiceTestUtil.nextLong()); newAnnouncementsDelivery.setUserId(ServiceTestUtil.nextLong()); newAnnouncementsDelivery.setType(ServiceTestUtil.randomString()); newAnnouncementsDelivery.setEmail(ServiceTestUtil.randomBoolean()); newAnnouncementsDelivery.setSms(ServiceTestUtil.randomBoolean()); newAnnouncementsDelivery.setWebsite(ServiceTestUtil.randomBoolean()); _persistence.update(newAnnouncementsDelivery, false); AnnouncementsDelivery existingAnnouncementsDelivery = _persistence.findByPrimaryKey(newAnnouncementsDelivery.getPrimaryKey()); Assert.assertEquals( existingAnnouncementsDelivery.getDeliveryId(), newAnnouncementsDelivery.getDeliveryId()); Assert.assertEquals( existingAnnouncementsDelivery.getCompanyId(), newAnnouncementsDelivery.getCompanyId()); Assert.assertEquals( existingAnnouncementsDelivery.getUserId(), newAnnouncementsDelivery.getUserId()); Assert.assertEquals( existingAnnouncementsDelivery.getType(), newAnnouncementsDelivery.getType()); Assert.assertEquals( existingAnnouncementsDelivery.getEmail(), newAnnouncementsDelivery.getEmail()); Assert.assertEquals(existingAnnouncementsDelivery.getSms(), newAnnouncementsDelivery.getSms()); Assert.assertEquals( existingAnnouncementsDelivery.getWebsite(), newAnnouncementsDelivery.getWebsite()); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { AnnouncementsDelivery newAnnouncementsDelivery = addAnnouncementsDelivery(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( AnnouncementsDelivery.class, AnnouncementsDelivery.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq("deliveryId", newAnnouncementsDelivery.getDeliveryId())); List<AnnouncementsDelivery> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); AnnouncementsDelivery existingAnnouncementsDelivery = result.get(0); Assert.assertEquals(existingAnnouncementsDelivery, newAnnouncementsDelivery); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { AnnouncementsDelivery newAnnouncementsDelivery = addAnnouncementsDelivery(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( AnnouncementsDelivery.class, AnnouncementsDelivery.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("deliveryId")); Object newDeliveryId = newAnnouncementsDelivery.getDeliveryId(); dynamicQuery.add(RestrictionsFactoryUtil.in("deliveryId", new Object[] {newDeliveryId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingDeliveryId = result.get(0); Assert.assertEquals(existingDeliveryId, newDeliveryId); }