Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetcher OttoBib #5125

Closed
wants to merge 10 commits into from
Closed

Fetcher OttoBib #5125

wants to merge 10 commits into from

Conversation

allisonsampaio
Copy link
Contributor

@allisonsampaio allisonsampaio commented Jul 14, 2019

I developed the fetcher to use ottobib, then after it try the ebook.de and chimbori.com is made the requisition for ottobib. #2581

@Siedlerchr
Copy link
Member

look at the WebFetchersTest class under JabRef/src/test/java/org/jabref/logic/importer/WebFetchersTest.java
You need to remove your new fetcher from the list of expected fetchers, that should resolve the erros

@allisonsampaio allisonsampaio mentioned this pull request Jul 14, 2019
@allisonsampaio
Copy link
Contributor Author

look at the WebFetchersTest class under JabRef/src/test/java/org/jabref/logic/importer/WebFetchersTest.java
You need to remove your new fetcher from the list of expected fetchers, that should resolve the erros

Hi @Siedlerchr ! Thanks for answering me. I think the problem with WebFetchersTest has been fixed.

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution , looks good to me know!
Just remove the unused method and add a change log entry, e.g. We improved fetching bibtex data from an ISBN

}

@Override
public void doPostCleanup(BibEntry entry) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove that method if it's not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the method I was not using. I'll do the unit test soon.

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot, please also add a unit test for the new fetcher

Copy link
Member

@Siedlerchr Siedlerchr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Now it's good!
If a second JabRef dev gives his okay, we can merge (Ideally a PR should be always reviewed by at least 2 JabRef devs)

@Siedlerchr Siedlerchr added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jul 15, 2019
Copy link
Member

@LinusDietz LinusDietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some rather nitpicky, but hopefully useful remarks. Functionality looks good, though. Can be merged after addressing the comments.


try {
postResponse = Unirest.post(BASE_URL)
.asString();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this into the line before

* @return null, because the identifier is passed using form data. This method is not used.
*/
@Override
public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these exceptions. They can never be thrown.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LinusDietz You are right that those exceptions can never be thrown, but the Exception declaration is coming from the interface IdBasedParserFetcher

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not possible to implement the ottobib fetcher by properly overwriting getURLForID as e.g here:

@Override
public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException {
this.ensureThatIsbnIsValid(identifier);
URIBuilder uriBuilder = new URIBuilder(BASE_URL);
uriBuilder.addParameter("isbn", identifier);
return uriBuilder.build().toURL();
}

I don't really see why the performSearchById has to be overwritten (which is more work as you have to manually post the request and parse the response).


HttpResponse<String> postResponse;

String BASE_URL = "https://www.ottobib.com/isbn/" + identifier + "/bibtex";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would propose to make BASE_URL final.

Also, I would prefer a String.format(): String.format("https://www.ottobib.com/isbn/%s/bibtex", identifier);

public class IsbnViaOttoBibFetcherTest extends AbstractIsbnFetcherTest {

@BeforeEach
public void setUp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to convert this into a static method createSampleBibEntry(). See Java by Comparison, "Favor Standalone Tests".

bibEntry.setField("isbn", "978-2-8195-02746");
bibEntry.setField("url", "https://www.ottobib.com/isbn/9782819502746/bibtex");

fetcher = new IsbnViaOttoBibFetcher(mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move fetcher into the respective tests to adhere to the 'given-then-when' structure of tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of interest to learn something, but doesn't this give (needless ?) code duplication especially since all tests are of the form "for-input-x-verify-output-y". If the state of the fetcher needs to be varied then a test of the form

    @Test
    public void test() throws FetcherException {
        fetcher.setSomething(value);

        Entry fetchedEntry = fetcher.fetch(input);

        assertEquals(expected, fetchedEntry);
    }

still perfectly adheres to the usual test pattern.

@LinusDietz LinusDietz added fetcher and removed status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Jul 16, 2019
Siedlerchr added a commit that referenced this pull request Aug 18, 2019
Fetcher does not return bibtex data in plain text, instead it's part of an html text area

Fix ISBN tests
Update user agent


Follow up from #5125
@Siedlerchr Siedlerchr mentioned this pull request Aug 18, 2019
6 tasks
@Siedlerchr
Copy link
Member

Superseeded by #5196

@Siedlerchr Siedlerchr closed this Aug 18, 2019
github-actions bot pushed a commit that referenced this pull request Dec 1, 2020
a20406d Added name of the editors of a given edition (#5140)
9881fc5 Ping on push, not PR, document role of dist-updater (#5137)
04668cc Create nouvelles-perspectives-en-sciences-sociales.csl (#5063)
1d94e21 Update bursa-uludag-universitesi-saglik-bilimleri-enstitusu.csl (#5047)
84f3893 Add Harvard style for Metropolia University of Applied Sciences (#5086)
8e43e79 Create opto-electronic-advances.csl (#5135)
36e4fba Update society-for-american-archaeology.csl (#5124)
69ca360 St. Paul Canon Law new style (#5138)
b490ab0 Update and rename st-paul-university-faculty-of-canon-law.csl to saint-paul-university-faculty-of-canon-law.csl
b498116 There is no en-CA locale
3c35f28 Metadata
7059cca Create tu-dortmund-agvm.csl (#5088)
c321c98 Create new Citation type (#5093)
a7edc8d Update international-organization.csl (#5103)
3d1a052 The AWS load balancer is messing things up (#5133)
ca3839b Fix sort by a single macro (#5136)
5d1a7e8 Update chungara-revista-de-antropologia-chilena.csl (#5123)
cd75d5d ping distribution-updater (#5132)
dcf473a Update wirtschaftsuniversitat-wien-health-care-management.csl (#5125)
a87085e Fix Harvard Praxisforschung Editors (#5130)
d4176ca Switch automated tests to Github Actions (#5111)
726d0d8 Radiology, MPP, CORR -- small fixes: https://forums.zotero.org/discussion/85883/doi-radiology#latest https://forums.zotero.org/discussion/51058/style-request-molecular-plant-pathology#latest https://forums.zotero.org/discussion/85678/citing-style-clinical-orthopaedics-and-related-research#latest
e23db68 Update to la-trobe-university-harvard style (#5119)
c54b278 Create wirtschaftsuniversitat-wien-health-care-management.csl (#5110)
62fb019 Create austral-entomology.csl (#5118)
afa328c Update iso690-author-date-en.csl (#5113)
5468dce Update iso690-author-date-fr-no-abstract.csl (#5112)
98af86c Update iso690-numeric-fr.csl (#5115)
09f84c4 Update iso690-author-date-fr.csl (#5114)
178a9e4 Fix current biology to superscript
1fa5ce7 Create droit-belge-centre-de-droit-prive-ulb.csl (#5107)
3a6a4bc Fix file modes (#5106)
48f50e5 Create chungara-revista-de-antropologia-chilena.csl (#5096)
1e848f8 Create the-journal-of-the-indian-law-institute.csl (#5100)
856524c Create molecular-biology.csl (#5101)
eeebbf4 Create harvard-harper-adams-university.csl (#5104)
d90993d Fix tests
d4037bf WIP: St Paul Canon Law style

git-subtree-dir: src/main/resources/csl-styles
git-subtree-split: a20406d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants