@Test(dependsOnMethods = {"storeEntity"}) @Rollback(value = false) @Transactional(value = TxType.NEVER) public void getPagination() throws IOException, PreviewTooLongException { Assert.assertEquals(printerProjectDao.getRowCount(), 2); List<PrinterProject> projects = printerProjectDao.get(0, 1, GalleryOrder.ALPHABETIC, null, null, null, null); Assert.assertEquals(projects.size(), 1); projects = printerProjectDao.get(100, 1, GalleryOrder.ALPHABETIC, null, null, null, null); Assert.assertEquals(projects.size(), 0); }
@Test(dependsOnMethods = {"storeEntity"}) @Rollback(value = false) @Transactional(value = TxType.NEVER) public void getByCategory() throws IOException, PreviewTooLongException { Assert.assertEquals(printerProjectDao.getRowCount(), 2); List<PrinterProject> projects = printerProjectDao.get(0, 100, GalleryOrder.RECENT, null, null, "sports", null); Assert.assertEquals(projects.size(), 1); // First project must be the obtained. Assert.assertTrue(comparePrinterProjects(projects.get(0), project1)); projects = printerProjectDao.get(0, 100, GalleryOrder.RECENT, null, null, "cinema", null); Assert.assertEquals(projects.size(), 2); }
@Test @Rollback(value = false) @Transactional(value = TxType.NEVER) public void storeEntity() throws IOException, PreviewTooLongException { Assert.assertEquals(printerProjectDao.getRowCount(), 0); project1 = createPrinterProject( PROJECT_1_NAME, PROJECT_1_DESCRIPTION, PROJECT_1_TAGS, PROJECT_1_CATEGORIES, ImageTools.loadImageFromResource(PROJECT_1_PREVIEW_FILE), PROJECT_1_USER); printerProjectDao.makePersistent(project1); Assert.assertNotNull(project1.getId()); Assert.assertEquals(printerProjectDao.getRowCount(), 1); // Retrieve from database PrinterProject projectRetrieved = printerProjectDao.get(project1.getId()); // Check new object. Assert.assertTrue(comparePrinterProjects(project1, projectRetrieved)); // Add new Project project2 = createPrinterProject( PROJECT_2_NAME, PROJECT_2_DESCRIPTION, PROJECT_2_TAGS, PROJECT_2_CATEGORIES, ImageTools.loadImageFromResource(PROJECT_2_PREVIEW_FILE), PROJECT_2_USER); printerProjectDao.makePersistent(project2); Assert.assertNotNull(project2.getId()); Assert.assertEquals(printerProjectDao.getRowCount(), 2); }
@Test(dependsOnMethods = {"storeEntity"}) @Rollback(value = false) @Transactional(value = TxType.NEVER) public void getByUser() throws IOException, PreviewTooLongException { Assert.assertEquals(printerProjectDao.getRowCount(), 2); List<PrinterProject> projects = printerProjectDao.get(0, 100, GalleryOrder.RECENT, null, null, null, PROJECT_1_USER); Assert.assertEquals(projects.size(), 2); }