@@ -117,11 +117,13 @@ void importMultipleEntriesInSingleFile() throws IOException, URISyntaxException
117
117
assertEquals (Optional .of ("Inproceedings book title" ), testEntry .getField (StandardField .BOOKTITLE ));
118
118
119
119
BibEntry expectedEntry5 = new BibEntry (StandardEntryType .Proceedings )
120
- .withField (StandardField .KEYWORDS , "Female" );
120
+ .withField (StandardField .KEYWORDS , "Female" )
121
+ .withField (StandardField .PMID , "96578310" );
121
122
assertEquals (expectedEntry5 , entries .get (5 ));
122
123
123
124
BibEntry expectedEntry6 = new BibEntry (StandardEntryType .Misc )
124
- .withField (StandardField .KEYWORDS , "Female" );
125
+ .withField (StandardField .KEYWORDS , "Female" )
126
+ .withField (StandardField .PMID , "45984220" );
125
127
assertEquals (expectedEntry6 , entries .get (6 ));
126
128
}
127
129
@@ -158,19 +160,49 @@ private void assertImportOfMedlineFileEqualsBibtexFile(String medlineFile, Strin
158
160
159
161
@ Test
160
162
void multiLineComments () throws IOException {
161
- try (BufferedReader reader = readerForString ("PMID-22664220" + "\n " + "CON - Comment1" + "\n " + "CIN - Comment2"
162
- + "\n " + "EIN - Comment3" + "\n " + "EFR - Comment4" + "\n " + "CRI - Comment5" + "\n " + "CRF - Comment6"
163
- + "\n " + "PRIN- Comment7" + "\n " + "PROF- Comment8" + "\n " + "RPI - Comment9" + "\n " + "RPF - Comment10"
164
- + "\n " + "RIN - Comment11" + "\n " + "ROF - Comment12" + "\n " + "UIN - Comment13" + "\n "
165
- + "UOF - Comment14" + "\n " + "SPIN- Comment15" + "\n " + "ORI - Comment16" )) {
163
+ try (BufferedReader reader = readerForString ("""
164
+ PMID-22664220
165
+ CON - Comment1
166
+ CIN - Comment2\
167
+
168
+ EIN - Comment3
169
+ EFR - Comment4
170
+ CRI - Comment5
171
+ CRF - Comment6\
172
+
173
+ PRIN- Comment7
174
+ PROF- Comment8
175
+ RPI - Comment9
176
+ RPF - Comment10\
177
+
178
+ RIN - Comment11
179
+ ROF - Comment12
180
+ UIN - Comment13
181
+ UOF - Comment14
182
+ SPIN- Comment15
183
+ ORI - Comment16""" )) {
166
184
List <BibEntry > actualEntries = importer .importDatabase (reader ).getDatabase ().getEntries ();
167
185
BibEntry expectedEntry = new BibEntry ();
168
186
187
+ expectedEntry .setField (StandardField .PMID , "22664220" );
169
188
expectedEntry .setField (StandardField .COMMENT ,
170
- "Comment1" + "\n " + "Comment2" + "\n " + "Comment3" + "\n " + "Comment4" + "\n " + "Comment5" + "\n "
171
- + "Comment6" + "\n " + "Comment7" + "\n " + "Comment8" + "\n " + "Comment9" + "\n "
172
- + "Comment10" + "\n " + "Comment11" + "\n " + "Comment12" + "\n " + "Comment13" + "\n "
173
- + "Comment14" + "\n " + "Comment15" + "\n " + "Comment16" );
189
+ """
190
+ Comment1
191
+ Comment2
192
+ Comment3
193
+ Comment4
194
+ Comment5
195
+ Comment6
196
+ Comment7
197
+ Comment8
198
+ Comment9
199
+ Comment10
200
+ Comment11
201
+ Comment12
202
+ Comment13
203
+ Comment14
204
+ Comment15
205
+ Comment16""" );
174
206
assertEquals (Collections .singletonList (expectedEntry ), actualEntries );
175
207
}
176
208
}
@@ -184,6 +216,7 @@ void keyWords() throws IOException {
184
216
List <BibEntry > actualEntries = importer .importDatabase (reader ).getDatabase ().getEntries ();
185
217
186
218
BibEntry expectedEntry = new BibEntry ();
219
+ expectedEntry .setField (StandardField .PMID , "22664795" );
187
220
expectedEntry .setField (StandardField .KEYWORDS , "Female, Male" );
188
221
189
222
assertEquals (Collections .singletonList (expectedEntry ), actualEntries );
@@ -200,7 +233,7 @@ void withNbibFile() throws IOException, URISyntaxException {
200
233
}
201
234
202
235
@ Test
203
- void withMultipleEntries () throws IOException , URISyntaxException {
236
+ void withMultipleEntriesInvalidFormat () throws IOException , URISyntaxException {
204
237
Path file = Path .of (MedlinePlainImporter .class .getResource ("MedlinePlainImporterStringOutOfBounds.txt" ).toURI ());
205
238
206
239
List <BibEntry > entries = importer .importDatabase (file ).getDatabase ().getEntries ();
@@ -229,14 +262,20 @@ void nullReader() throws IOException {
229
262
230
263
@ Test
231
264
void allArticleTypes () throws IOException {
232
- try (BufferedReader reader = readerForString ("PMID-22664795" + "\n " + "MH - Female\n " + "PT - journal article"
233
- + "\n " + "PT - classical article" + "\n " + "PT - corrected and republished article" + "\n "
234
- + "PT - introductory journal article" + "\n " + "PT - newspaper article" )) {
265
+ try (BufferedReader reader = readerForString ("""
266
+ PMID-22664795
267
+ MH - Female
268
+ PT - journal article\
269
+
270
+ PT - classical article
271
+ PT - corrected and republished article
272
+ PT - introductory journal article
273
+ PT - newspaper article""" )) {
235
274
List <BibEntry > actualEntries = importer .importDatabase (reader ).getDatabase ().getEntries ();
236
275
237
- BibEntry expectedEntry = new BibEntry ();
238
- expectedEntry . setType ( StandardEntryType . Article );
239
- expectedEntry . setField (StandardField .KEYWORDS , "Female " );
276
+ BibEntry expectedEntry = new BibEntry (StandardEntryType . Article )
277
+ . withField ( StandardField . KEYWORDS , "Female" )
278
+ . withField (StandardField .PMID , "22664795 " );
240
279
241
280
assertEquals (Collections .singletonList (expectedEntry ), actualEntries );
242
281
}
0 commit comments