@@ -35,6 +35,7 @@ public StubImporterPreferences() {
3535 true , // persistCustomKeys
3636 List .of (), // catalogs
3737 null , // defaultPlainCitationParser
38+ 5 , // citationsRelationsStoreTTL
3839 Collections .emptyMap () // searchEngineUrlTemplates
3940 );
4041 }
@@ -62,9 +63,12 @@ static Stream<Arguments> specialCharactersProvider() {
6263 @ ParameterizedTest
6364 @ MethodSource ("specialCharactersProvider" )
6465 void getShortScienceSearchURLEncodesSpecialCharacters (String title ) {
66+ ImporterPreferences stubPreferences = new StubImporterPreferences ();
67+ ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
68+
6569 BibEntry entry = new BibEntry ();
6670 entry .setField (StandardField .TITLE , title );
67- Optional <String > url = getShortScienceSearchURL (entry );
71+ Optional <String > url = linkCreator . getShortScienceSearchURL (entry );
6872 assertTrue (url .isPresent ());
6973 assertTrue (urlIsValid (url .get ()));
7074 }
@@ -77,8 +81,11 @@ void getShortScienceSearchURLEncodesSpecialCharacters(String title) {
7781 "'JabRef bibliography management', 'https://www.shortscience.org/internalsearch?q=JabRef%20bibliography%20management'"
7882 })
7983 void getShortScienceSearchURLEncodesCharacters (String title , String expectedUrl ) {
84+ ImporterPreferences stubPreferences = new StubImporterPreferences ();
85+ ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
86+
8087 BibEntry entry = new BibEntry ().withField (StandardField .TITLE , title );
81- Optional <String > url = getShortScienceSearchURL (entry );
88+ Optional <String > url = linkCreator . getShortScienceSearchURL (entry );
8289 assertEquals (Optional .of (expectedUrl ), url );
8390 }
8491
@@ -91,15 +98,17 @@ void getShortScienceSearchURLReturnsEmptyOnMissingTitle() {
9198 assertEquals (Optional .empty (), linkCreator .getShortScienceSearchURL (entry ));
9299 }
93100
94- @ Test
95- void getShortScienceSearchURLLinksToSearchResults () {
101+ @ ParameterizedTest
102+ @ CsvSource ({
103+ "JabRef bibliography management, https://www.shortscience.org/internalsearch?q=JabRef%20bibliography%20management" ,
104+ "Machine learning, https://www.shortscience.org/internalsearch?q=Machine%20learning" ,
105+ })
106+ void getShortScienceSearchURLLinksToSearchResults (String title , String expectedUrl ) {
96107 ImporterPreferences stubPreferences = new StubImporterPreferences ();
97108 ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
98109
99- // Take an arbitrary article name
100- BibEntry entry = new BibEntry ().withField (StandardField .TITLE , "JabRef bibliography management" );
110+ BibEntry entry = new BibEntry ().withField (StandardField .TITLE , title );
101111 Optional <String > url = linkCreator .getShortScienceSearchURL (entry );
102- // Expected behaviour is to link to the search results page, /internalsearch
103- assertEquals (Optional .of ("https://www.shortscience.org/internalsearch?q=JabRef%20bibliography%20management" ), url );
112+ assertEquals (Optional .of (expectedUrl ), url );
104113 }
105114}
0 commit comments