1
|
/**
|
2
|
* Copyright (C) 2009 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.strategy.cache.reference;
|
10
|
|
11
|
import static org.junit.Assert.assertEquals;
|
12
|
|
13
|
import java.lang.reflect.InvocationTargetException;
|
14
|
import java.lang.reflect.Method;
|
15
|
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.joda.time.DateTime;
|
18
|
import org.junit.Assert;
|
19
|
import org.junit.Before;
|
20
|
import org.junit.BeforeClass;
|
21
|
import org.junit.Test;
|
22
|
|
23
|
import eu.etaxonomy.cdm.common.DOI;
|
24
|
import eu.etaxonomy.cdm.common.URI;
|
25
|
import eu.etaxonomy.cdm.common.UTF8;
|
26
|
import eu.etaxonomy.cdm.model.agent.Person;
|
27
|
import eu.etaxonomy.cdm.model.agent.Team;
|
28
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
29
|
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
|
30
|
import eu.etaxonomy.cdm.model.reference.IArticle;
|
31
|
import eu.etaxonomy.cdm.model.reference.IBook;
|
32
|
import eu.etaxonomy.cdm.model.reference.IBookSection;
|
33
|
import eu.etaxonomy.cdm.model.reference.IGeneric;
|
34
|
import eu.etaxonomy.cdm.model.reference.IJournal;
|
35
|
import eu.etaxonomy.cdm.model.reference.IWebPage;
|
36
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
37
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
38
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
39
|
|
40
|
/**
|
41
|
* Copy of {@link ArticleDefaultCacheStrategyTest} to test the {@link ReferenceDefaultCacheStrategy}.
|
42
|
*
|
43
|
* @author a.mueller
|
44
|
* @since 25.05.2016
|
45
|
*/
|
46
|
public class ReferenceDefaultCacheStrategyTest {
|
47
|
|
48
|
@SuppressWarnings("unused")
|
49
|
private static final Logger logger = Logger.getLogger(ReferenceDefaultCacheStrategyTest.class);
|
50
|
|
51
|
private static final String SEP = TimePeriod.SEP;
|
52
|
|
53
|
//article
|
54
|
private static IArticle article1;
|
55
|
private static IJournal journal1;
|
56
|
private static Team articleTeam1;
|
57
|
private static Team articleTeam2;
|
58
|
|
59
|
//book // book section
|
60
|
private static IBook book1;
|
61
|
private static Team bookTeam1;
|
62
|
|
63
|
//book section
|
64
|
private static IBookSection bookSection1;
|
65
|
private static Team sectionTeam1;
|
66
|
|
67
|
//CdDvd
|
68
|
private static Reference cdDvd;
|
69
|
private static String cdDvdTitle;
|
70
|
|
71
|
//Generic
|
72
|
private static IGeneric generic1;
|
73
|
private static Team genericTeam1;
|
74
|
|
75
|
//WebPage
|
76
|
private static IWebPage webPage1;
|
77
|
private static Team webPageTeam1;
|
78
|
|
79
|
//common
|
80
|
private static ReferenceDefaultCacheStrategy defaultStrategy;
|
81
|
|
82
|
@BeforeClass
|
83
|
public static void setUpBeforeClass() throws Exception {
|
84
|
defaultStrategy = ReferenceDefaultCacheStrategy.NewInstance();
|
85
|
}
|
86
|
|
87
|
@Before
|
88
|
public void setUp() throws Exception {
|
89
|
//article
|
90
|
article1 = ReferenceFactory.newArticle();
|
91
|
article1.setCacheStrategy(defaultStrategy);
|
92
|
journal1 = ReferenceFactory.newJournal();
|
93
|
journal1.setCacheStrategy(defaultStrategy);
|
94
|
articleTeam1 = Team.NewInstance();
|
95
|
articleTeam2 = Team.NewInstance();
|
96
|
articleTeam1.setTitleCache("Team1", true);
|
97
|
articleTeam1.setNomenclaturalTitle("T.", true);
|
98
|
articleTeam2.setTitleCache("Team2", true);
|
99
|
articleTeam2.setNomenclaturalTitle("TT.", true);
|
100
|
|
101
|
//book / section
|
102
|
book1 = ReferenceFactory.newBook();
|
103
|
book1.setCacheStrategy(defaultStrategy);
|
104
|
bookTeam1 = Team.NewTitledInstance("Book Author", "TT.");
|
105
|
bookSection1 = ReferenceFactory.newBookSection();
|
106
|
sectionTeam1 = Team.NewTitledInstance("Section Author", "T.");
|
107
|
|
108
|
//CdDvd
|
109
|
cdDvd = ReferenceFactory.newCdDvd();
|
110
|
cdDvd.setCacheStrategy(defaultStrategy);
|
111
|
cdDvdTitle = "A nice CD title";
|
112
|
cdDvd.setTitle(cdDvdTitle);
|
113
|
String publisher = "An ugly publisher"; //not yet implemented
|
114
|
String place = "A beutiful place"; //not yet implemented
|
115
|
VerbatimTimePeriod publicationDate = VerbatimTimePeriod.NewVerbatimInstance(1999, 2001);
|
116
|
cdDvd.setDatePublished(publicationDate);
|
117
|
|
118
|
//Generic
|
119
|
generic1 = ReferenceFactory.newGeneric();
|
120
|
generic1.setCacheStrategy(defaultStrategy);
|
121
|
genericTeam1 = Team.NewTitledInstance("Authorteam", "AT.");
|
122
|
|
123
|
//WebPage
|
124
|
webPage1 = ReferenceFactory.newWebPage();
|
125
|
webPage1.setCacheStrategy(defaultStrategy);
|
126
|
webPageTeam1 = Team.NewTitledInstance("Authorteam, D.", "AT.");
|
127
|
}
|
128
|
|
129
|
//**************************** TESTS ***********************************
|
130
|
|
131
|
@Test
|
132
|
public void testArticleGetTitleCache(){
|
133
|
journal1.setTitle("My journal");
|
134
|
((Reference)journal1).setAuthorship(articleTeam2); //incorrect use anyway
|
135
|
article1.setInJournal(journal1);
|
136
|
article1.setAuthorship(articleTeam1);
|
137
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
138
|
Assert.assertEquals("Team1 1975: "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
|
139
|
article1.setTitle("My article");
|
140
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
|
141
|
|
142
|
article1.setInJournal(null);
|
143
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
|
144
|
}
|
145
|
|
146
|
@Test
|
147
|
//This test is just to show that setInJournal(null) now resets caches #1815
|
148
|
public void testSetInJournal(){
|
149
|
journal1.setTitle("My journal");
|
150
|
((Reference)journal1).setAuthorship(articleTeam2);
|
151
|
article1.setTitle("My article");
|
152
|
article1.setInJournal(journal1);
|
153
|
article1.setAuthorship(articleTeam1);
|
154
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
155
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
|
156
|
|
157
|
article1.setInJournal(null);
|
158
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
|
159
|
article1.setDatePublished(null);
|
160
|
Assert.assertEquals("Team1: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
|
161
|
}
|
162
|
|
163
|
//#6496
|
164
|
@Test
|
165
|
public void testArticleGetTitleCacheWithPages(){
|
166
|
journal1.setTitle("My journal");
|
167
|
((Reference)journal1).setAuthorship(articleTeam2);
|
168
|
article1.setTitle("My article");
|
169
|
article1.setInJournal(journal1);
|
170
|
article1.setAuthorship(articleTeam1);
|
171
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
172
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
|
173
|
article1.setPages("12-22");
|
174
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal: 12-22.", article1.getTitleCache());
|
175
|
|
176
|
article1.setVolume("7");
|
177
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal 7: 12-22.", article1.getTitleCache());
|
178
|
|
179
|
article1.setSeriesPart("II");
|
180
|
//TODO unclear if punctuation is correct
|
181
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal, II, 7: 12-22.", article1.getTitleCache());
|
182
|
}
|
183
|
|
184
|
@Test
|
185
|
public void testArticleGetAbbrevTitleCache(){
|
186
|
|
187
|
journal1.setTitle("My journal");
|
188
|
journal1.setTitle("M. Journ.");
|
189
|
((Reference)journal1).setAuthorship(articleTeam2);
|
190
|
article1.setTitle("My article");
|
191
|
article1.setInJournal(journal1);
|
192
|
article1.setAuthorship(articleTeam1);
|
193
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
194
|
article1.setAbbrevTitle("M. Art.");
|
195
|
Assert.assertEquals("T. 1975: M. Art. "+UTF8.EN_DASH+" M. Journ.", article1.getAbbrevTitleCache());
|
196
|
article1.setVolume("7");
|
197
|
Assert.assertEquals("T. 1975: M. Art. "+UTF8.EN_DASH+" M. Journ. 7.", article1.getAbbrevTitleCache());
|
198
|
|
199
|
article1.setInJournal(null);
|
200
|
article1.setTitleCache(null, false);
|
201
|
Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH + " " +ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + " 7.", article1.getTitleCache());
|
202
|
}
|
203
|
|
204
|
@Test
|
205
|
public void testArticleGetTitleWithoutYearAndAuthor() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
|
206
|
journal1.setTitle("My journal");
|
207
|
journal1.setAbbrevTitle("My journ.");
|
208
|
((Reference)journal1).setAuthorship(articleTeam2);
|
209
|
article1.setTitle("My article");
|
210
|
article1.setAbbrevTitle("My art.");
|
211
|
article1.setInJournal(journal1);
|
212
|
article1.setAuthorship(articleTeam1);
|
213
|
article1.setVolume("34");
|
214
|
article1.setSeriesPart("ser. 2");
|
215
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
216
|
Method method = ReferenceDefaultCacheStrategy.class.getDeclaredMethod("getTitleWithoutYearAndAuthor", Reference.class, boolean.class, boolean.class);
|
217
|
method.setAccessible(true);
|
218
|
Assert.assertEquals("My article. " + UTF8.EN_DASH + " My journal, ser. 2, 34", method.invoke(defaultStrategy, article1, false, false));
|
219
|
Assert.assertEquals("My art. " + UTF8.EN_DASH + " My journ., ser. 2, 34", method.invoke(defaultStrategy, article1, true, false));
|
220
|
Assert.assertEquals("in My journal, ser. 2, 34", method.invoke(defaultStrategy, article1, false, true));
|
221
|
Assert.assertEquals("in My journ., ser. 2, 34", method.invoke(defaultStrategy, article1, true, true));
|
222
|
}
|
223
|
|
224
|
@Test
|
225
|
public void testArticleOldExistingBugs(){
|
226
|
journal1.setTitle("Univ. Calif. Publ. Bot.");
|
227
|
((Reference)journal1).setAuthorship(null);
|
228
|
|
229
|
Team articleAuthor = Team.NewTitledInstance("Babc. & Stebbins", "Babc. & Stebbins");
|
230
|
article1.setTitle("");
|
231
|
article1.setInJournal(journal1);
|
232
|
article1.setAuthorship(articleAuthor);
|
233
|
article1.setVolume("18");
|
234
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1943));
|
235
|
Assert.assertEquals("Babc. & Stebbins 1943: "+UTF8.EN_DASH+" Univ. Calif. Publ. Bot. 18.", defaultStrategy.getTitleCache((Reference)article1));
|
236
|
}
|
237
|
|
238
|
// ******************* Book ****************************/
|
239
|
|
240
|
@Test
|
241
|
public void testBookGetTitleCache0(){
|
242
|
book1.setTitle("My book");
|
243
|
book1.setAuthorship(bookTeam1);
|
244
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
245
|
Assert.assertEquals("Unexpected title cache.", "Book Author 1975: My book.", book1.getTitleCache());
|
246
|
|
247
|
book1.setTitleCache(null, false);
|
248
|
book1.setEdition("ed. 3");
|
249
|
Assert.assertEquals("Unexpected title cache.", "Book Author 1975: My book, ed. 3.", book1.getTitleCache());
|
250
|
|
251
|
VerbatimTimePeriod newDatePublished = TimePeriodParser.parseStringVerbatim("1975 (after Aug.)");
|
252
|
book1.setDatePublished(newDatePublished);
|
253
|
book1.setTitleCache(null, false);
|
254
|
//TODO this behaviour needs to be discussed. Maybe better the complete date published string should be returned.
|
255
|
Assert.assertEquals("Unexpected title cache.", "Book Author: My book, ed. 3.", book1.getTitleCache());
|
256
|
|
257
|
book1.setPages("1-405");
|
258
|
Assert.assertEquals("Unexpected title cache.", "Book Author: My book, ed. 3: 1-405.", book1.getTitleCache());
|
259
|
|
260
|
}
|
261
|
|
262
|
@Test
|
263
|
public void testBookGetTitleCache1(){
|
264
|
//series
|
265
|
IBook book1 = ReferenceFactory.newBook();
|
266
|
book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
|
267
|
book1.setVolume("Fasc. 11");
|
268
|
book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
|
269
|
//TODO needs to be discussed
|
270
|
Assert.assertEquals("Unexpected abbrev title cache", "1955: Acta Inst. Bot. Acad. Sci. URSS Fasc. 11.", book1.getTitleCache());
|
271
|
book1.setSeriesPart("1");
|
272
|
//TODO needs to be discussed
|
273
|
Assert.assertEquals("Unexpected abbrev title cache", "1955: Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11.", book1.getTitleCache());
|
274
|
}
|
275
|
|
276
|
// ***************************** Book Section ************************/
|
277
|
|
278
|
//9529 and others
|
279
|
@Test
|
280
|
public void testBookSectionGetTitleCache(){
|
281
|
String bookSetionTitle = "My chapter";
|
282
|
book1.setTitle("My book");
|
283
|
book1.setAuthorship(bookTeam1);
|
284
|
bookSection1.setTitle(bookSetionTitle);
|
285
|
bookSection1.setInBook(book1);
|
286
|
bookSection1.setAuthorship(sectionTeam1);
|
287
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
288
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1975: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
289
|
|
290
|
book1.setDatePublished((VerbatimTimePeriod)null);
|
291
|
bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
|
292
|
bookSection1.setTitleCache(null, false);
|
293
|
book1.setTitleCache(null, false);
|
294
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
295
|
//with in-ref year (ignore if there is ref year)
|
296
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
|
297
|
bookSection1.setTitleCache(null, false);
|
298
|
book1.setTitleCache(null, false);
|
299
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
300
|
//with series part
|
301
|
bookSection1.setTitleCache(null, false);
|
302
|
book1.setTitleCache(null, false);
|
303
|
book1.setSeriesPart("2");
|
304
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
|
305
|
//without section title
|
306
|
bookSection1.setTitle(null);
|
307
|
bookSection1.setTitleCache(null, false);
|
308
|
book1.setTitleCache(null, false);
|
309
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976 "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
|
310
|
bookSection1.setTitle(bookSetionTitle);
|
311
|
|
312
|
//#6496, 9529, 9530
|
313
|
bookSection1.setPages("33-38");
|
314
|
bookSection1.setTitleCache(null, false);
|
315
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter, pp. 33-38. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
|
316
|
bookSection1.setPages("v");
|
317
|
bookSection1.setTitleCache(null, false);
|
318
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter, p. v. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
|
319
|
bookSection1.setPages(null);
|
320
|
|
321
|
bookSection1.setInBook(null);
|
322
|
bookSection1.setTitleCache(null, false);
|
323
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: - undefined book -.", bookSection1.getTitleCache());
|
324
|
}
|
325
|
|
326
|
@Test
|
327
|
//This test is just to show that setInBook(null) now resets caches #1815
|
328
|
public void testBookSectionSetInBook(){
|
329
|
book1.setTitle("My book");
|
330
|
book1.setAuthorship(bookTeam1);
|
331
|
bookSection1.setTitle("My chapter");
|
332
|
bookSection1.setInBook(book1);
|
333
|
bookSection1.setAuthorship(sectionTeam1);
|
334
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
335
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1975: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
336
|
book1.setDatePublished((VerbatimTimePeriod)null);
|
337
|
bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
|
338
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
339
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
|
340
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
|
341
|
|
342
|
bookSection1.setInBook(null);
|
343
|
Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: - undefined book -.", bookSection1.getTitleCache());
|
344
|
}
|
345
|
|
346
|
@Test
|
347
|
public void testBookSectionRealExample(){
|
348
|
Team bookTeam = Team.NewTitledInstance("Chaudhary S. A.(ed.)", "Chaudhary S. A.(ed.)");
|
349
|
IBook book = ReferenceFactory.newBook();
|
350
|
book.setTitle("Flora of the Kingdom of Saudi Arabia");
|
351
|
book.setAuthorship(bookTeam);
|
352
|
book.setVolume("2(3)");
|
353
|
book.setPlacePublished("Riyadh");
|
354
|
book.setPublisher("National Herbarium");
|
355
|
book.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(2000));
|
356
|
|
357
|
Team sectionTeam = Team.NewTitledInstance("Chaudhary S. A.", "Chaudhary S. A.");
|
358
|
IBookSection bookSection = ReferenceFactory.newBookSection();
|
359
|
bookSection.setTitle("73. Hedypnois - 87. Crepis");
|
360
|
bookSection.setInBook(book);
|
361
|
bookSection.setAuthorship(sectionTeam);
|
362
|
bookSection.setPages("222-251");
|
363
|
Assert.assertEquals("Chaudhary S. A. 2000: 73. Hedypnois - 87. Crepis, pp. 222-251. "+UTF8.EN_DASH+" In: Chaudhary S. A.(ed.), Flora of the Kingdom of Saudi Arabia 2(3).", bookSection.getTitleCache());
|
364
|
|
365
|
}
|
366
|
|
367
|
@Test
|
368
|
public void testSectionInArticle(){
|
369
|
//#9326, #3764
|
370
|
Reference journal = ReferenceFactory.newJournal();
|
371
|
journal.setTitle("Phytotaxa");
|
372
|
Reference article = ReferenceFactory.newArticle();
|
373
|
String articleTitle = "New diatom species Navicula davidovichii from Vietnam (Southeast Asia)";
|
374
|
article.setTitle(articleTitle);
|
375
|
Team articleTeam = Team.NewTitledInstance("Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P.", null);
|
376
|
article.setAuthorship(articleTeam);
|
377
|
article.setInJournal(journal);
|
378
|
article.setVolume("452(1)");
|
379
|
article.setPages("83-91");
|
380
|
article.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
|
381
|
article.setDoi(DOI.fromString("10.11646/phytotaxa.452.1.8"));
|
382
|
Reference section = ReferenceFactory.newSection();
|
383
|
Team sectionTeam = Team.NewTitledInstance("Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P.", null);
|
384
|
section.setAuthorship(sectionTeam);
|
385
|
section.setInReference(article);
|
386
|
|
387
|
Assert.assertEquals("Unexpected title cache.",
|
388
|
"Chudaev, D.A., Glushchenko, A., Kulikovskiy, M. & Kociolek, J.P. 2020 "+UTF8.EN_DASH+" In: "
|
389
|
+ "Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P., "
|
390
|
+ "New diatom species Navicula davidovichii from Vietnam (Southeast Asia). "+UTF8.EN_DASH+" Phytotaxa 452(1).",
|
391
|
section.getTitleCache());
|
392
|
}
|
393
|
|
394
|
@Test
|
395
|
public void testSectionInJournal(){
|
396
|
//#9326, #3764
|
397
|
Reference journal = ReferenceFactory.newJournal();
|
398
|
journal.setTitle("Phytotaxa");
|
399
|
Reference section = ReferenceFactory.newSection();
|
400
|
Team sectionTeam = Team.NewTitledInstance("Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P.", null);
|
401
|
section.setAuthorship(sectionTeam);
|
402
|
|
403
|
section.setInReference(journal);
|
404
|
section.setVolume("452(1)");
|
405
|
section.setDatePublished(TimePeriodParser.parseStringVerbatim("8 Jul 2020"));
|
406
|
|
407
|
Assert.assertEquals("Unexpected title cache.",
|
408
|
"Kulikovskiy, M., Chudaev, D.A., Glushchenko, A., Kuznetsova, I. & Kociolek, J.P. 2020 "+UTF8.EN_DASH+" In: "
|
409
|
+ "Phytotaxa 452(1).",
|
410
|
section.getTitleCache());
|
411
|
}
|
412
|
|
413
|
@Test
|
414
|
public void testSectionInBookSection(){
|
415
|
//#9326, #3764
|
416
|
Reference book = ReferenceFactory.newBook();
|
417
|
book.setTitle("Species Plantarum");
|
418
|
Team bookAuthor = Team.NewTitledInstance("Linne", null);
|
419
|
book.setAuthorship(bookAuthor);
|
420
|
book.setVolume("3");
|
421
|
Reference bookSection = ReferenceFactory.newBookSection();
|
422
|
String bookSectionTitle = "Trees";
|
423
|
bookSection.setTitle(bookSectionTitle);
|
424
|
Team bookSectionTeam = Team.NewTitledInstance("Chapter author", null);
|
425
|
bookSection.setAuthorship(bookSectionTeam);
|
426
|
bookSection.setInBook(book);
|
427
|
bookSection.setPages("83-91");
|
428
|
bookSection.setDatePublished(TimePeriodParser.parseStringVerbatim("1752"));
|
429
|
bookSection.setDoi(DOI.fromString("10.12345/speciesplantarum.3"));
|
430
|
Reference section = ReferenceFactory.newSection();
|
431
|
Team sectionTeam = Team.NewTitledInstance("Section author", null);
|
432
|
section.setAuthorship(sectionTeam);
|
433
|
section.setInReference(bookSection);
|
434
|
|
435
|
Assert.assertEquals("Unexpected title cache.",
|
436
|
"Section author 1752 "+UTF8.EN_DASH+" In: Chapter author, Trees, pp. 83-91. "+UTF8.EN_DASH+" In: Linne, Species Plantarum 3.",
|
437
|
section.getTitleCache());
|
438
|
}
|
439
|
|
440
|
@Test
|
441
|
public void testCdDvdGetTitleWithoutYearAndAuthor() {
|
442
|
String result = TitleWithoutYearAndAuthorHelper.getTitleWithoutYearAndAuthor(cdDvd, false, false);
|
443
|
assertEquals(cdDvdTitle, result);
|
444
|
}
|
445
|
|
446
|
//TODO missing publicationPlace and publisher has to be discussed
|
447
|
@Test
|
448
|
public void testCdDvdGetTitleCache() {
|
449
|
String result = defaultStrategy.getTitleCache(cdDvd);
|
450
|
//TODO position of year needs to be discussed
|
451
|
assertEquals("1999"+SEP+"2001: " + cdDvdTitle + ".", result);
|
452
|
}
|
453
|
|
454
|
// *************************** GENERIC *****************************************/
|
455
|
|
456
|
@Test
|
457
|
public void testGenericGetTitleCache(){
|
458
|
generic1.setTitle("auct.");
|
459
|
Assert.assertEquals("Unexpected title cache.", "auct.", generic1.getTitleCache());
|
460
|
}
|
461
|
|
462
|
@Test
|
463
|
public void testGenericGetTitleCache2(){
|
464
|
generic1.setTitle("Part Title");
|
465
|
IBook book1 = ReferenceFactory.newBook();
|
466
|
book1.setTitle("My book title");
|
467
|
book1.setAuthorship(genericTeam1);
|
468
|
Reference inRef = (Reference)book1;
|
469
|
generic1.setInReference(inRef);
|
470
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
471
|
Assert.assertEquals("Unexpected title cache.", "Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
|
472
|
}
|
473
|
|
474
|
@Test
|
475
|
public void testGenericGetAbbrevTitleCache(){
|
476
|
generic1.setTitle("Part Title");
|
477
|
generic1.setAbbrevTitle("Pt. Tit.");
|
478
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1987"));
|
479
|
IBook book1 = ReferenceFactory.newBook();
|
480
|
book1.setTitle("My book title");
|
481
|
book1.setAbbrevTitle("My bk. tit.");
|
482
|
book1.setAuthorship(genericTeam1); //TODO handling not yet defined
|
483
|
Reference inRef = (Reference)book1;
|
484
|
generic1.setInReference(inRef);
|
485
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
486
|
generic1.setAbbrevTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
487
|
//TODO needs discussion
|
488
|
Assert.assertEquals("Unexpected abbrev title cache.", "1987: Pt. Tit. "+UTF8.EN_DASH+" In: AT., My bk. tit.", generic1.getAbbrevTitleCache());
|
489
|
Assert.assertEquals("Title cache must still be the same", "1987: Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
|
490
|
|
491
|
//protected
|
492
|
generic1.setAbbrevTitleCache("My prot. abb. tit. in a bk.", true);
|
493
|
Assert.assertEquals("Unexpected abbrev title cache.", "My prot. abb. tit. in a bk.", generic1.getAbbrevTitleCache());
|
494
|
Assert.assertEquals("Unexpected title cache.", "1987: Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
|
495
|
}
|
496
|
|
497
|
@Test
|
498
|
public void testGenericGetTitleCacheWithoutInRef(){
|
499
|
generic1.setTitle("My generic title");
|
500
|
generic1.setAuthorship(genericTeam1);
|
501
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
502
|
Assert.assertEquals("Unexpected title cache.", "Authorteam: My generic title.", generic1.getTitleCache());
|
503
|
}
|
504
|
|
505
|
@Test
|
506
|
public void testGenericAuthorOnly(){
|
507
|
generic1.setAuthorship(genericTeam1);
|
508
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
509
|
Assert.assertEquals("Unexpected title cache.", "Authorteam.", generic1.getTitleCache());
|
510
|
}
|
511
|
|
512
|
@Test
|
513
|
public void testGenericYearAndAuthorOnly(){
|
514
|
generic1.setAuthorship(genericTeam1);
|
515
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1792"));
|
516
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
517
|
Assert.assertEquals("Unexpected title cache.", "Authorteam 1792.", generic1.getTitleCache());
|
518
|
}
|
519
|
|
520
|
//#4338
|
521
|
@Test
|
522
|
public void testGenericMissingVolume(){
|
523
|
generic1.setTitle("My generic");
|
524
|
generic1.setAuthorship(genericTeam1);
|
525
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1883-1884"));
|
526
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
527
|
generic1.setVolume("7");
|
528
|
Assert.assertEquals("Authorteam 1883"+SEP+"1884: My generic 7.", generic1.getTitleCache());
|
529
|
Assert.assertEquals("AT. 1883"+SEP+"1884: My generic 7.", generic1.getAbbrevTitleCache());
|
530
|
|
531
|
//inRef
|
532
|
Reference generic2 = ReferenceFactory.newGeneric();
|
533
|
generic2.setTitle("My InRef");
|
534
|
Person person2 = Person.NewTitledInstance("InRefAuthor");
|
535
|
generic2.setAuthorship(person2);
|
536
|
generic2.setDatePublished(TimePeriodParser.parseStringVerbatim("1885"));
|
537
|
generic1.setInReference(generic2);
|
538
|
|
539
|
//only reference has a volume
|
540
|
// Assert.assertEquals("in InRefAuthor, My InRef 7: 55. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail1));
|
541
|
// Assert.assertEquals("Authorteam - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getTitleCache());
|
542
|
// Assert.assertEquals("AT. - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getAbbrevTitleCache());
|
543
|
|
544
|
//both have a volume
|
545
|
generic2.setVolume("9"); //still unclear what should happen if you have such dirty data
|
546
|
// Assert.assertEquals("Authorteam - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getTitleCache());
|
547
|
// Assert.assertEquals("AT. - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getAbbrevTitleCache());
|
548
|
|
549
|
//only inref has volume
|
550
|
generic1.setVolume(null);
|
551
|
Assert.assertEquals("Authorteam 1883"+SEP+"1884: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9.", generic1.getTitleCache());
|
552
|
Assert.assertEquals("AT. 1883"+SEP+"1884: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9.", generic1.getAbbrevTitleCache());
|
553
|
}
|
554
|
|
555
|
// ********************************** WEB PAGE ********************************************/
|
556
|
|
557
|
@Test
|
558
|
//still preliminary, may be modified in future
|
559
|
public void testWebPageGetTitleCache(){
|
560
|
webPage1.setUri(URI.create("http://flora.huji.ac.il"));
|
561
|
Assert.assertEquals("Unexpected title cache.",
|
562
|
"http://flora.huji.ac.il",
|
563
|
webPage1.getTitleCache());
|
564
|
|
565
|
webPage1.setTitle("Flora of Israel Online");
|
566
|
webPage1.setAuthorship(webPageTeam1);
|
567
|
webPage1.setAccessed(DateTime.parse("2001-01-05"));
|
568
|
Assert.assertEquals("Unexpected title cache.",
|
569
|
"Authorteam, D.: Flora of Israel Online "+UTF8.EN_DASH+" http://flora.huji.ac.il [accessed 2001-01-05]",
|
570
|
webPage1.getTitleCache());
|
571
|
}
|
572
|
|
573
|
// @Test
|
574
|
// //WebPages should usually not be used as nomencl.reference, therefore this is less important
|
575
|
// public void testWebPageGetAbbrevTitleCache(){
|
576
|
// webPage1.setTitle("auct.");
|
577
|
// Assert.assertEquals("Unexpected title cache.", "auct.", webPage1.getTitleCache());
|
578
|
// }
|
579
|
|
580
|
}
|