Skip to content

Commit 52cc2e4

Browse files
committed
Introduce TestBookmark.
1 parent 83a6429 commit 52cc2e4

3 files changed

Lines changed: 50 additions & 6 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2022 Matthieu Gautier <mgautier@kymeria.fr>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3 of the License, or
7+
* any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17+
* MA 02110-1301, USA.
18+
*/
19+
20+
package org.kiwix.test.libkiwix;
21+
22+
import org.kiwix.libkiwix.Bookmark;
23+
24+
public class TestBookmark
25+
{
26+
private Bookmark inner;
27+
public Bookmark inner() { return inner; }
28+
public TestBookmark() { inner = new Bookmark(); }
29+
public TestBookmark(Bookmark _inner) { inner = _inner; }
30+
31+
public void setBookId(String bookId) { inner.setBookId(bookId); }
32+
public void setBookTitle(String bookTitle) { inner.setBookTitle(bookTitle); }
33+
public void setUrl(String url) { inner.setUrl(url); }
34+
public void setTitle(String title) { inner.setTitle(title); }
35+
public void setLanguage(String language) { inner.setLanguage(language); }
36+
public void setDate(String date) { inner.setDate(date); }
37+
38+
public String getBookId() { return inner.getBookId(); }
39+
public String getBookTitle() { return inner.getBookTitle(); }
40+
public String getUrl() { return inner.getUrl(); }
41+
public String getTitle() { return inner.getTitle(); }
42+
public String getLanguage() { return inner.getLanguage(); }
43+
public String getDate() { return inner.getDate(); }
44+
}

lib/src/test/org/kiwix/test/libkiwix/TestLibrary.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
import org.kiwix.libkiwix.Library;
2323
import org.kiwix.test.libzim.TestArchive;
24+
import org.kiwix.test.libkiwix.TestBookmark;
2425
import org.kiwix.libzim.Searcher;
2526
import org.kiwix.libkiwix.Filter;
26-
import org.kiwix.libkiwix.Book;
2727
import org.kiwix.libkiwix.JNIKiwixException;
28-
import org.kiwix.libkiwix.Bookmark;
28+
import java.util.stream.Stream;
2929

3030
public class TestLibrary
3131
{
@@ -56,7 +56,7 @@ public class TestLibrary
5656
public String[] getBooksCreators() { return inner.getBooksCreators(); }
5757
public String[] getBooksPublishers() { return inner.getBooksPublishers(); }
5858

59-
public void addBookmark(Bookmark bookmark) { inner.addBookmark(bookmark); }
59+
public void addBookmark(TestBookmark bookmark) { inner.addBookmark(bookmark.inner()); }
6060
public boolean removeBookmark(String zimId, String url) { return inner.removeBookmark(zimId, url); }
61-
public Bookmark[] getBookmarks(boolean onlyValidBookmarks) { return inner.getBookmarks(onlyValidBookmarks); }
61+
public TestBookmark[] getBookmarks(boolean onlyValidBookmarks) { return Stream.of(inner.getBookmarks(onlyValidBookmarks)).map(b -> new TestBookmark(b)).toArray(TestBookmark[]::new); }
6262
}

lib/src/test/test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void testBookMark() throws ZimFileFormatException, JNIKiwixException {
154154
TestBook book = new TestBook();
155155
book.update(archive);
156156
lib.addBook(book);
157-
Bookmark bookmark = new Bookmark();
157+
TestBookmark bookmark = new TestBookmark();
158158
bookmark.setBookId(book.getId());
159159
bookmark.setTitle(book.getTitle());
160160
bookmark.setUrl(book.getUrl());
@@ -163,7 +163,7 @@ public void testBookMark() throws ZimFileFormatException, JNIKiwixException {
163163
bookmark.setBookTitle(book.getName());
164164
// add bookmark to library
165165
lib.addBookmark(bookmark);
166-
Bookmark[] bookmarkArray = lib.getBookmarks(true);
166+
TestBookmark[] bookmarkArray = lib.getBookmarks(true);
167167
assertEquals(1, bookmarkArray.length);
168168
bookmark = bookmarkArray[0];
169169
// test saved bookmark

0 commit comments

Comments
 (0)