@Test public void testUpdateExisting() throws Exception { long pk = ServiceTestUtil.nextLong(); ShoppingItemPrice newShoppingItemPrice = _persistence.create(pk); newShoppingItemPrice.setItemId(ServiceTestUtil.nextLong()); newShoppingItemPrice.setMinQuantity(ServiceTestUtil.nextInt()); newShoppingItemPrice.setMaxQuantity(ServiceTestUtil.nextInt()); newShoppingItemPrice.setPrice(ServiceTestUtil.nextDouble()); newShoppingItemPrice.setDiscount(ServiceTestUtil.nextDouble()); newShoppingItemPrice.setTaxable(ServiceTestUtil.randomBoolean()); newShoppingItemPrice.setShipping(ServiceTestUtil.nextDouble()); newShoppingItemPrice.setUseShippingFormula(ServiceTestUtil.randomBoolean()); newShoppingItemPrice.setStatus(ServiceTestUtil.nextInt()); _persistence.update(newShoppingItemPrice); ShoppingItemPrice existingShoppingItemPrice = _persistence.findByPrimaryKey(newShoppingItemPrice.getPrimaryKey()); Assert.assertEquals( existingShoppingItemPrice.getItemPriceId(), newShoppingItemPrice.getItemPriceId()); Assert.assertEquals(existingShoppingItemPrice.getItemId(), newShoppingItemPrice.getItemId()); Assert.assertEquals( existingShoppingItemPrice.getMinQuantity(), newShoppingItemPrice.getMinQuantity()); Assert.assertEquals( existingShoppingItemPrice.getMaxQuantity(), newShoppingItemPrice.getMaxQuantity()); AssertUtils.assertEquals(existingShoppingItemPrice.getPrice(), newShoppingItemPrice.getPrice()); AssertUtils.assertEquals( existingShoppingItemPrice.getDiscount(), newShoppingItemPrice.getDiscount()); Assert.assertEquals(existingShoppingItemPrice.getTaxable(), newShoppingItemPrice.getTaxable()); AssertUtils.assertEquals( existingShoppingItemPrice.getShipping(), newShoppingItemPrice.getShipping()); Assert.assertEquals( existingShoppingItemPrice.getUseShippingFormula(), newShoppingItemPrice.getUseShippingFormula()); Assert.assertEquals(existingShoppingItemPrice.getStatus(), newShoppingItemPrice.getStatus()); }
@Test public void testDynamicQueryByPrimaryKeyExisting() throws Exception { ShoppingItemPrice newShoppingItemPrice = addShoppingItemPrice(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( ShoppingItemPrice.class, ShoppingItemPrice.class.getClassLoader()); dynamicQuery.add( RestrictionsFactoryUtil.eq("itemPriceId", newShoppingItemPrice.getItemPriceId())); List<ShoppingItemPrice> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); ShoppingItemPrice existingShoppingItemPrice = result.get(0); Assert.assertEquals(existingShoppingItemPrice, newShoppingItemPrice); }
@Test public void testDynamicQueryByProjectionExisting() throws Exception { ShoppingItemPrice newShoppingItemPrice = addShoppingItemPrice(); DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass( ShoppingItemPrice.class, ShoppingItemPrice.class.getClassLoader()); dynamicQuery.setProjection(ProjectionFactoryUtil.property("itemPriceId")); Object newItemPriceId = newShoppingItemPrice.getItemPriceId(); dynamicQuery.add(RestrictionsFactoryUtil.in("itemPriceId", new Object[] {newItemPriceId})); List<Object> result = _persistence.findWithDynamicQuery(dynamicQuery); Assert.assertEquals(1, result.size()); Object existingItemPriceId = result.get(0); Assert.assertEquals(existingItemPriceId, newItemPriceId); }