summaryrefslogtreecommitdiffstats
path: root/MobiReader/test/tests
diff options
context:
space:
mode:
authorJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-26 17:58:33 +0200
committerJustyna Ilczuk <justyna.ilczuk@gmail.com>2013-04-26 17:58:33 +0200
commit1db006b285cf25cebe612895fed2980fbf934a99 (patch)
tree5f5a9924f779691e75f72276fe09ba693ae715fb /MobiReader/test/tests
parent1598363031728e576e530e24b7ba3cdcd84d9b3a (diff)
downloadmobi_reader-master.tar.gz
mobi_reader-master.tar.bz2
mobi_reader-master.tar.xz
mobi_reader-master.zip
database handling works perfectly nowHEADmaster
Diffstat (limited to 'MobiReader/test/tests')
-rw-r--r--MobiReader/test/tests/SqlConnectionJUnitTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/MobiReader/test/tests/SqlConnectionJUnitTest.java b/MobiReader/test/tests/SqlConnectionJUnitTest.java
index 4176cc8..89b6365 100644
--- a/MobiReader/test/tests/SqlConnectionJUnitTest.java
+++ b/MobiReader/test/tests/SqlConnectionJUnitTest.java
@@ -67,6 +67,7 @@ public class SqlConnectionJUnitTest {
assertEquals(path, bookFromDB.getPathToContent());
}
+
@Test
public void testAddingFewBooksOfSameAuthorToDb() throws ClassNotFoundException
{
@@ -92,6 +93,34 @@ public class SqlConnectionJUnitTest {
}
@Test
+ public void testGettingAllBooksFromDb() throws ClassNotFoundException
+ {
+ String title1 = "Title1";
+ String title2 = "Title2";
+ String title3 = "Title3";
+ String authorName1 = "Gepetto";
+ String authorName2 = "Geronimo";
+ Author gepetto = new Author(authorName1);
+ Author geronimo = new Author(authorName2);
+ String path = "/somepath/book.txt";
+ ArrayList<Book> books = new ArrayList<>();
+ books.add(new Book(title1, gepetto, path));
+ books.add(new Book(title2, gepetto, path));
+ books.add(new Book(title3, gepetto, path));
+ books.add(new Book(title1, geronimo, path));
+ books.add(new Book(title2, geronimo, path));
+ books.add(new Book(title3, geronimo, path));
+ handler.addBooks(books);
+ ArrayList<Book> booksFromDB = handler.getAllBooks();
+ assertEquals(books.size(), booksFromDB.size());
+ for(int i = 0; i < books.size(); i++ )
+ {
+ assertEquals(books.get(i).getTitle(), booksFromDB.get(i).getTitle());
+ assertEquals(books.get(i).getAuthor().getName(), booksFromDB.get(i).getAuthor().getName());
+ }
+ }
+
+ @Test
public void testAddingAuthorToDb() throws Exception
{
String authorName = "Geronimo";
@@ -103,6 +132,7 @@ public class SqlConnectionJUnitTest {
assertEquals(additionalInfo, authorFromDB.getAdditionalInfo());
}
+
@Test
public void testAddingTheSameAuthorToDbFewTimes() throws Exception
{