@Test public void testGetByImageType() throws Exception { commodityViewDAO.create(commodityView); List<CommodityView> c = commodityViewDAO.getByImageType(ImageType.bmp); commodityView.setId(c.get(0).getId()); assertEquals(c.get(0), commodityView); }
@Test public void testCreate() throws Exception { commodityViewDAO.create(commodityView); List<CommodityView> c = commodityViewDAO.getByIdCommodity(commodityView.getIdCommodity()); commodityView.setId(c.get(0).getId()); assertEquals(c.get(0), commodityView); }
@Test public void testDelete() throws Exception { commodityViewDAO.create(commodityView); List<CommodityView> c = commodityViewDAO.getByIdCommodity(commodity.getId()); for (CommodityView test : c) commodityViewDAO.delete(test.getId()); assertThat( "Expected empty List ", commodityViewDAO.getByIdCommodity(commodity.getId()).isEmpty(), is(true)); }
@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); }