@@ -35,6 +35,7 @@ public StubImporterPreferences() {
35
35
true , // persistCustomKeys
36
36
List .of (), // catalogs
37
37
null , // defaultPlainCitationParser
38
+ 5 , // citationsRelationsStoreTTL
38
39
Collections .emptyMap () // searchEngineUrlTemplates
39
40
);
40
41
}
@@ -62,9 +63,12 @@ static Stream<Arguments> specialCharactersProvider() {
62
63
@ ParameterizedTest
63
64
@ MethodSource ("specialCharactersProvider" )
64
65
void getShortScienceSearchURLEncodesSpecialCharacters (String title ) {
66
+ ImporterPreferences stubPreferences = new StubImporterPreferences ();
67
+ ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
68
+
65
69
BibEntry entry = new BibEntry ();
66
70
entry .setField (StandardField .TITLE , title );
67
- Optional <String > url = getShortScienceSearchURL (entry );
71
+ Optional <String > url = linkCreator . getShortScienceSearchURL (entry );
68
72
assertTrue (url .isPresent ());
69
73
assertTrue (urlIsValid (url .get ()));
70
74
}
@@ -77,8 +81,11 @@ void getShortScienceSearchURLEncodesSpecialCharacters(String title) {
77
81
"'JabRef bibliography management', 'https://www.shortscience.org/internalsearch?q=JabRef%20bibliography%20management'"
78
82
})
79
83
void getShortScienceSearchURLEncodesCharacters (String title , String expectedUrl ) {
84
+ ImporterPreferences stubPreferences = new StubImporterPreferences ();
85
+ ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
86
+
80
87
BibEntry entry = new BibEntry ().withField (StandardField .TITLE , title );
81
- Optional <String > url = getShortScienceSearchURL (entry );
88
+ Optional <String > url = linkCreator . getShortScienceSearchURL (entry );
82
89
assertEquals (Optional .of (expectedUrl ), url );
83
90
}
84
91
@@ -91,15 +98,17 @@ void getShortScienceSearchURLReturnsEmptyOnMissingTitle() {
91
98
assertEquals (Optional .empty (), linkCreator .getShortScienceSearchURL (entry ));
92
99
}
93
100
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 ) {
96
107
ImporterPreferences stubPreferences = new StubImporterPreferences ();
97
108
ExternalLinkCreator linkCreator = new ExternalLinkCreator (stubPreferences );
98
109
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 );
101
111
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 );
104
113
}
105
114
}
0 commit comments