File indexing completed on 2024-05-12 16:46:23
0001 /*************************************************************************** 0002 Copyright (C) 2012 Robby Stephenson <robby@periapsis.org> 0003 ***************************************************************************/ 0004 0005 /*************************************************************************** 0006 * * 0007 * This program is free software; you can redistribute it and/or * 0008 * modify it under the terms of the GNU General Public License as * 0009 * published by the Free Software Foundation; either version 2 of * 0010 * the License or (at your option) version 3 or any later version * 0011 * accepted by the membership of KDE e.V. (or its successor approved * 0012 * by the membership of KDE e.V.), which shall act as a proxy * 0013 * defined in Section 14 of version 3 of the license. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, * 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0018 * GNU General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 0022 * * 0023 ***************************************************************************/ 0024 0025 #undef QT_NO_CAST_FROM_ASCII 0026 0027 #include "springerfetchertest.h" 0028 0029 #include "../fetch/springerfetcher.h" 0030 #include "../entry.h" 0031 #include "../collections/bibtexcollection.h" 0032 #include "../collectionfactory.h" 0033 #include "../utils/datafileregistry.h" 0034 0035 #include <QTest> 0036 0037 QTEST_GUILESS_MAIN( SpringerFetcherTest ) 0038 0039 SpringerFetcherTest::SpringerFetcherTest() : AbstractFetcherTest() { 0040 } 0041 0042 void SpringerFetcherTest::initTestCase() { 0043 Tellico::DataFileRegistry::self()->addDataLocation(QFINDTESTDATA("../../xslt/springer2tellico.xsl")); 0044 Tellico::RegisterCollection<Tellico::Data::BibtexCollection> registerBibtex(Tellico::Data::Collection::Bibtex, "bibtex"); 0045 0046 m_fieldValues.insert(QStringLiteral("doi"), QStringLiteral("10.1007/BF02174211")); 0047 // m_fieldValues.insert(QStringLiteral("entry-type"), QStringLiteral("article")); 0048 m_fieldValues.insert(QStringLiteral("title"), QStringLiteral("The roughening transition of the three-dimensional Ising interface: A Monte Carlo study")); 0049 m_fieldValues.insert(QStringLiteral("author"), QStringLiteral("Hasenbusch, M.; Meyer, S.; Pütz, M.")); 0050 m_fieldValues.insert(QStringLiteral("volume"), QStringLiteral("85")); 0051 m_fieldValues.insert(QStringLiteral("journal"), QStringLiteral("Journal of Statistical Physics")); 0052 m_fieldValues.insert(QStringLiteral("publisher"), QStringLiteral("Springer")); 0053 m_fieldValues.insert(QStringLiteral("year"), QStringLiteral("1996")); 0054 m_fieldValues.insert(QStringLiteral("entry-type"), QStringLiteral("article")); 0055 } 0056 0057 void SpringerFetcherTest::testTitle() { 0058 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Title, 0059 QStringLiteral("roughening transition of the three-dimensional Ising interface")); 0060 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SpringerFetcher(this)); 0061 0062 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0063 0064 QCOMPARE(results.size(), 1); 0065 Tellico::Data::EntryPtr entry = results.at(0); 0066 0067 QHashIterator<QString, QString> i(m_fieldValues); 0068 while(i.hasNext()) { 0069 i.next(); 0070 QCOMPARE(entry->field(i.key()), i.value()); 0071 } 0072 QVERIFY(entry->field(QStringLiteral("abstract")).contains(QStringLiteral("Kosterlitz-Thouless"))); 0073 } 0074 0075 void SpringerFetcherTest::testAuthor() { 0076 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Person, 0077 QStringLiteral("Albert Einstein")); 0078 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SpringerFetcher(this)); 0079 0080 Tellico::Data::EntryList results = DO_FETCH(fetcher, request); 0081 0082 QVERIFY(results.size() > 1); 0083 } 0084 0085 void SpringerFetcherTest::testKeyword() { 0086 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::Keyword, 0087 QStringLiteral("Hadron-hadron scattering")); 0088 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SpringerFetcher(this)); 0089 0090 // spring fetcher defaults to 10 at a time, expect 11 to check search continue 0091 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 11); 0092 0093 QCOMPARE(results.size(), 11); 0094 } 0095 0096 void SpringerFetcherTest::testISBN() { 0097 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::ISBN, 0098 QStringLiteral("978-3-7643-7436-5")); 0099 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SpringerFetcher(this)); 0100 0101 // there are several results for the same ISBN here 0102 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0103 0104 QCOMPARE(results.size(), 1); 0105 } 0106 0107 void SpringerFetcherTest::testDOI() { 0108 Tellico::Fetch::FetchRequest request(Tellico::Data::Collection::Bibtex, Tellico::Fetch::DOI, 0109 m_fieldValues.value(QStringLiteral("doi"))); 0110 Tellico::Fetch::Fetcher::Ptr fetcher(new Tellico::Fetch::SpringerFetcher(this)); 0111 0112 Tellico::Data::EntryList results = DO_FETCH1(fetcher, request, 1); 0113 0114 QCOMPARE(results.size(), 1); 0115 Tellico::Data::EntryPtr entry = results.at(0); 0116 0117 QHashIterator<QString, QString> i(m_fieldValues); 0118 while(i.hasNext()) { 0119 i.next(); 0120 QCOMPARE(entry->field(i.key()), i.value()); 0121 } 0122 QVERIFY(entry->field(QStringLiteral("abstract")).contains(QStringLiteral("Kosterlitz-Thouless"))); 0123 }