-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Added api keys from default build file #12816
base: main
Are you sure you want to change the base?
Added api keys from default build file #12816
Conversation
updated CompositeSearchBasedFetcher as well to use api keys where applicable
@@ -72,12 +78,16 @@ void performSearchOnEmptyQuery(Set<SearchBasedFetcher> fetchers) throws Exceptio | |||
"Fetchers: {arguments}") | |||
@MethodSource("performSearchParameters") | |||
void performSearchOnNonEmptyQuery(Set<SearchBasedFetcher> fetchers) throws Exception { | |||
List fetcherNames = fetchers.stream().map(fetcher-> fetcher.getName()).collect(Collectors.toUnmodifiableList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lambda expression has unnecessary parentheses and arrow syntax could be replaced with method reference: fetcher::getName for better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you use IntelliJ IDEA, it should propose you these changes, and you can just click on hint
Your code currently does not meet JabRef's code guidelines. We use Checkstyle to identify issues. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues. In case of issues with the import order, double check that you activated Auto Import. You can trigger fixing imports by pressing Ctrl+Alt+O to trigger Optimize Imports. |
changed to use optional variable where applicable
@trag-bot didn't find any issues in the code! ✅✨ |
JabRef CI uses ( env:
SpringerNatureAPIKey: ${{ secrets.SPRINGERNATUREAPIKEY_FOR_TESTS }}
AstrophysicsDataSystemAPIKey: ${{ secrets.AstrophysicsDataSystemAPIKey_FOR_TESTS }}
IEEEAPIKey: ${{ secrets.IEEEAPIKey_FOR_TESTS }}
BiodiversityHeritageApiKey: ${{ secrets.BiodiversityHeritageApiKey_FOR_TESTS}} This is put into
Which seems to be read by org.jabref.logic.util.BuildInfo#BuildInfo(). Thus, reading that in fetcher tests seems to be right.
|
I wonder why the fetcher tests worked before - haha |
@@ -25,10 +26,11 @@ class ScienceDirectTest { | |||
private final ImporterPreferences importerPreferences = mock(ImporterPreferences.class); | |||
private ScienceDirect finder; | |||
private BibEntry entry; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not remove empty lines separating blocks.
ObservableList<String> observableList = FXCollections.observableArrayList(fetcherNames); | ||
when(importerPreferences.getCatalogs()).thenReturn(observableList); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge these two lines - the name obsevableList
is not good.
@@ -72,12 +79,16 @@ void performSearchOnEmptyQuery(Set<SearchBasedFetcher> fetchers) throws Exceptio | |||
"Fetchers: {arguments}") | |||
@MethodSource("performSearchParameters") | |||
void performSearchOnNonEmptyQuery(Set<SearchBasedFetcher> fetchers) throws Exception { | |||
List fetcherNames = fetchers.stream().map(WebFetcher::getName).collect(Collectors.toUnmodifiableList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use .toList()
instead of .collect...
@@ -101,7 +112,15 @@ void performSearchOnNonEmptyQuery(Set<SearchBasedFetcher> fetchers) throws Excep | |||
static Stream<Arguments> performSearchParameters() { | |||
ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); | |||
ImporterPreferences importerPreferences = mock(ImporterPreferences.class); | |||
BuildInfo buildInfo = new BuildInfo(); | |||
when(importerPreferences.getApiKeys()).thenReturn(FXCollections.emptyObservableSet()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove this line to cause an error when an unknown key is retrieved? To catch errors early when a new fetcher is added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean by this comment. If I remove it the parameterized tests will start failing.
Should i create a whole new set of tests?
CompositeSearchBasedFetcher compositeFetcher = new CompositeSearchBasedFetcher(fetchers, importerPreferences, Integer.MAX_VALUE); | ||
FieldPreferences fieldPreferences = mock(FieldPreferences.class); | ||
when(fieldPreferences.getNonWrappableFields()).thenReturn(FXCollections.observableArrayList()); | ||
ImportCleanup cleanup = ImportCleanup.targeting(BibDatabaseMode.BIBTEX, fieldPreferences); | ||
|
||
List<BibEntry> compositeResult = compositeFetcher.performSearch("quantum"); | ||
compositeResult.forEach(cleanup::doPostCleanup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is OK for consistency reasons
Closes #12803
Added api keys from BuildInfo where applicable for the fetcher tests. Needed to do proper mocking for the ImporterPrefereces.getApiKey($IMPORTER_NAME)
CompositeSearchBasedFetcher updated with proper mocks as well to use api keys for the different fetchers.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)