From ff6469a34f0c21d18b6f001f5ff3e049ba9aa4b2 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Tue, 13 Jun 2023 17:38:18 +0200 Subject: [PATCH] Introduce TestEntry.java --- .../org/kiwix/test/libzim/TestArchive.java | 15 ++++---- .../test/org/kiwix/test/libzim/TestEntry.java | 36 +++++++++++++++++++ 2 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 lib/src/test/org/kiwix/test/libzim/TestEntry.java diff --git a/lib/src/test/org/kiwix/test/libzim/TestArchive.java b/lib/src/test/org/kiwix/test/libzim/TestArchive.java index 5546075..3bd447f 100644 --- a/lib/src/test/org/kiwix/test/libzim/TestArchive.java +++ b/lib/src/test/org/kiwix/test/libzim/TestArchive.java @@ -20,7 +20,6 @@ package org.kiwix.test.libzim; import org.kiwix.libzim.ZimFileFormatException; -import org.kiwix.libzim.Entry; import org.kiwix.libzim.Item; import org.kiwix.libzim.EntryIterator; import org.kiwix.libzim.Archive; @@ -62,20 +61,20 @@ public class TestArchive public boolean hasIllustration(int size) { return inner.hasIllustration(size); } public long[] getIllustrationSizes() { return inner.getIllustrationSizes(); } - public Entry getEntryByPath(String path) { return inner.getEntryByPath(path); } - public Entry getEntryByPath(int index) { return inner.getEntryByPath(index); } + public TestEntry getEntryByPath(String path) { return new TestEntry(inner.getEntryByPath(path)); } + public TestEntry getEntryByPath(int index) { return new TestEntry(inner.getEntryByPath(index)); } public boolean hasEntryByPath(String path) { return inner.hasEntryByPath(path); } - public Entry getEntryByTitle(String title) { return inner.getEntryByTitle(title); } - public Entry getEntryByTitle(int index) { return inner.getEntryByTitle(index); } + public TestEntry getEntryByTitle(String title) { return new TestEntry(inner.getEntryByTitle(title)); } + public TestEntry getEntryByTitle(int index) { return new TestEntry(inner.getEntryByTitle(index)); } public boolean hasEntryByTitle(String title) { return inner.hasEntryByTitle(title); } - public Entry getEntryByClusterOrder(int index) { return inner.getEntryByClusterOrder(index); } + public TestEntry getEntryByClusterOrder(int index) { return new TestEntry(inner.getEntryByClusterOrder(index)); } - public Entry getMainEntry() { return inner.getMainEntry(); } + public TestEntry getMainEntry() { return new TestEntry(inner.getMainEntry()); } public boolean hasMainEntry() { return inner.hasMainEntry(); } - public Entry getRandomEntry() { return inner.getRandomEntry(); } + public TestEntry getRandomEntry() { return new TestEntry(inner.getRandomEntry()); } public boolean hasFulltextIndex() { return inner.hasFulltextIndex(); } public boolean hasTitleIndex() { return inner.hasTitleIndex(); } diff --git a/lib/src/test/org/kiwix/test/libzim/TestEntry.java b/lib/src/test/org/kiwix/test/libzim/TestEntry.java new file mode 100644 index 0000000..188f92d --- /dev/null +++ b/lib/src/test/org/kiwix/test/libzim/TestEntry.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 Matthieu Gautier + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +package org.kiwix.test.libzim; + +import org.kiwix.libzim.Entry; +import org.kiwix.libzim.Item; + +public class TestEntry +{ + private Entry inner; + public TestEntry(Entry _inner) { inner = _inner; } + public boolean isRedirect() { return inner.isRedirect(); } + public String getTitle() { return inner.getTitle(); } + public String getPath() { return inner.getPath(); } + + public Item getItem(boolean follow) { return inner.getItem(follow); } + public Item getRedirect() { return inner.getRedirect(); } + public TestEntry getRedirectEntry() { return new TestEntry(inner.getRedirectEntry()); } +}