@Test public void testDeleteBookmark() { addTestVerse(); List<BookmarkDto> bookmarks = bookmarkControl.getAllBookmarks(); BookmarkDto todelete = bookmarks.get(0); bookmarkControl.deleteBookmark(todelete); bookmarks = bookmarkControl.getAllBookmarks(); for (BookmarkDto bookmark : bookmarks) { assertFalse("delete failed", bookmark.getId().equals(todelete.getId())); } }
/** @return */ private BookmarkDto addTestVerse() { try { currentTestVerse = getNextTestVerse(); BookmarkDto bookmark = new BookmarkDto(); bookmark.setVerse( VerseFactory.fromString( Versifications.instance().getVersification("KJV"), currentTestVerse)); BookmarkDto newDto = bookmarkControl.addBookmark(bookmark); return newDto; } catch (Exception e) { fail("Error in verse:" + currentTestVerse); } return null; }
@Test public void testGetAllBookmarks() { try { addTestVerse(); addTestVerse(); addTestVerse(); List<BookmarkDto> bookmarks = bookmarkControl.getAllBookmarks(); for (BookmarkDto dto : bookmarks) { System.out.println(dto.getId() + " " + dto.getVerse().getName()); } assertTrue(bookmarks.size() == 3); } catch (Exception e) { e.printStackTrace(); fail("exeption:" + e.getMessage()); } }
@Test public void testAddBookmark() { try { BookmarkDto newDto = addTestVerse(); assertEquals( "New Bookmark key incorrect. Test:" + currentTestVerse + " was:" + newDto.getVerse().getName(), newDto.getVerse().getName(), currentTestVerse); assertTrue("New Bookmark id incorrect", newDto.getId() > -1); } catch (Exception e) { e.printStackTrace(); fail("exeption:" + e.getMessage()); } }