public void testInsertError() { long lngCustId = System.currentTimeMillis(); String orderNum = "123"; SalesOrder salesOrder = new SalesOrder(); salesOrder.setSorCusId(lngCustId); salesOrder.setSorOrderNum(orderNum); try { salesOrderDao.save(salesOrder); HibernateUtil.getSession().flush(); Assert.fail(); } catch (PropertyValueException e) { } }
public void testUpdateSuccess() { long lngCustId = System.currentTimeMillis(); String orderNum = "123"; String newOrderNum = "321"; SalesOrder salesOrder = new SalesOrder(); salesOrder.setSorCusId(lngCustId); salesOrder.setSorOrderNum(orderNum); salesOrder.setSorTotalPrice(BigDecimal.ZERO); salesOrderDao.save(salesOrder); HibernateUtil.getSession().flush(); Long lngId = salesOrder.getSorId(); salesOrder = salesOrderDao.findById(lngId); salesOrder.setSorOrderNum(newOrderNum); salesOrderDao.save(salesOrder); HibernateUtil.getSession().flush(); salesOrder = salesOrderDao.findById(lngId); assertEquals(newOrderNum, salesOrder.getSorOrderNum()); }
public void testDeleteSuccess() { long lngCustId = System.currentTimeMillis(); String orderNum = "123"; SalesOrder salesOrder = new SalesOrder(); salesOrder.setSorCusId(lngCustId); salesOrder.setSorOrderNum(orderNum); salesOrder.setSorTotalPrice(BigDecimal.ZERO); salesOrderDao.save(salesOrder); HibernateUtil.getSession().flush(); Long lngId = salesOrder.getSorId(); salesOrder = salesOrderDao.findById(lngId); salesOrderDao.delete(salesOrder); Assert.assertTrue(true); }