private void fillDbTables() throws Exception { for (Category cat : categories) categoryDAO.create(cat); for (Producer p : producers) producerDAO.create(p); Long idProducer = producerDAO.getByName("Apple").getId(); Long idCategory = categoryDAO.getByName("Tablet").getId(); commodity.setIdProducer(idProducer); commodity.setIdCategory(idCategory); commodityDAO.create(commodity); commodity = commodityDAO.getByName("Ipad4"); commodityView.setIdCommodity(commodity.getId()); }
@Test public void testUpdate() throws Exception { commodityViewDAO.create(commodityView); List<CommodityView> c = commodityViewDAO.getByIdCommodity(commodity.getId()); CommodityView view = c.get(0); long id = view.getId(); long idCommodity = view.getIdCommodity(); someCommodityView = new CommodityView(); someCommodityView.setId(id); someCommodityView.setIdCommodity(idCommodity); someCommodityView.setCommodityPhoto(view.getCommodityPhoto()); someCommodityView.setCommodityPhotoType(ImageType.png); someCommodityView.setGalleryPhoto(true); commodityViewDAO.update(someCommodityView); CommodityView test = commodityViewDAO.getById(id); assertEquals(someCommodityView, test); }