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 org.apache.log4j.Logger;
|
14
|
import org.joda.time.DateTime;
|
15
|
import org.junit.Assert;
|
16
|
import org.junit.Before;
|
17
|
import org.junit.BeforeClass;
|
18
|
import org.junit.Test;
|
19
|
|
20
|
import eu.etaxonomy.cdm.common.URI;
|
21
|
import eu.etaxonomy.cdm.model.agent.Person;
|
22
|
import eu.etaxonomy.cdm.model.agent.Team;
|
23
|
import eu.etaxonomy.cdm.model.common.TimePeriod;
|
24
|
import eu.etaxonomy.cdm.model.common.VerbatimTimePeriod;
|
25
|
import eu.etaxonomy.cdm.model.reference.IArticle;
|
26
|
import eu.etaxonomy.cdm.model.reference.IBook;
|
27
|
import eu.etaxonomy.cdm.model.reference.IBookSection;
|
28
|
import eu.etaxonomy.cdm.model.reference.ICdDvd;
|
29
|
import eu.etaxonomy.cdm.model.reference.IDatabase;
|
30
|
import eu.etaxonomy.cdm.model.reference.IGeneric;
|
31
|
import eu.etaxonomy.cdm.model.reference.IJournal;
|
32
|
import eu.etaxonomy.cdm.model.reference.IWebPage;
|
33
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
34
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
35
|
import eu.etaxonomy.cdm.strategy.cache.agent.TeamDefaultCacheStrategy;
|
36
|
import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
|
37
|
|
38
|
/**
|
39
|
* Copy of {@link ArticleDefaultCacheStrategyTest} to test the {@link DefaultReferenceCacheStrategy}.
|
40
|
*
|
41
|
* @author a.mueller
|
42
|
* @since 25.05.2016
|
43
|
*/
|
44
|
public class DefaultReferenceCacheStrategyTest {
|
45
|
@SuppressWarnings("unused")
|
46
|
private static final Logger logger = Logger.getLogger(DefaultReferenceCacheStrategyTest.class);
|
47
|
|
48
|
private static final String SEP = TimePeriod.SEP;
|
49
|
|
50
|
//article
|
51
|
private static IArticle article1;
|
52
|
private static IJournal journal1;
|
53
|
private static Team articleTeam1;
|
54
|
private static Team articleTeam2;
|
55
|
|
56
|
//book // book section
|
57
|
private static IBook book1;
|
58
|
private static Team bookTeam1;
|
59
|
|
60
|
//book section
|
61
|
private static IBookSection bookSection1;
|
62
|
private static Team sectionTeam1;
|
63
|
|
64
|
//CdDvd
|
65
|
private static Reference cdDvd;
|
66
|
private static String cdDvdTitle;
|
67
|
|
68
|
//Generic
|
69
|
private static IGeneric generic1;
|
70
|
private static Team genericTeam1;
|
71
|
|
72
|
//WebPage
|
73
|
private static IWebPage webPage1;
|
74
|
private static Team webPageTeam1;
|
75
|
|
76
|
//common
|
77
|
private static DefaultReferenceCacheStrategy defaultStrategy;
|
78
|
private static final String detail1 = "55";
|
79
|
|
80
|
@BeforeClass
|
81
|
public static void setUpBeforeClass() throws Exception {
|
82
|
defaultStrategy = DefaultReferenceCacheStrategy.NewInstance();
|
83
|
}
|
84
|
|
85
|
@Before
|
86
|
public void setUp() throws Exception {
|
87
|
//article
|
88
|
article1 = ReferenceFactory.newArticle();
|
89
|
article1.setCacheStrategy(defaultStrategy);
|
90
|
journal1 = ReferenceFactory.newJournal();
|
91
|
journal1.setCacheStrategy(defaultStrategy);
|
92
|
articleTeam1 = Team.NewInstance();
|
93
|
articleTeam2 = Team.NewInstance();
|
94
|
articleTeam1.setTitleCache("Team1", true);
|
95
|
articleTeam1.setNomenclaturalTitle("T.", true);
|
96
|
articleTeam2.setTitleCache("Team2", true);
|
97
|
articleTeam2.setNomenclaturalTitle("TT.", true);
|
98
|
|
99
|
//book / section
|
100
|
book1 = ReferenceFactory.newBook();
|
101
|
book1.setCacheStrategy(defaultStrategy);
|
102
|
bookTeam1 = Team.NewTitledInstance("Book Author", "TT.");
|
103
|
bookSection1 = ReferenceFactory.newBookSection();
|
104
|
sectionTeam1 = Team.NewTitledInstance("Section Author", "T.");
|
105
|
|
106
|
//CdDvd
|
107
|
cdDvd = ReferenceFactory.newCdDvd();
|
108
|
cdDvd.setCacheStrategy(defaultStrategy);
|
109
|
cdDvdTitle = "A nice CD title";
|
110
|
cdDvd.setTitle(cdDvdTitle);
|
111
|
String publisher = "An ugly publisher"; //not yet implemented
|
112
|
String place = "A beutiful place"; //not yet implemented
|
113
|
VerbatimTimePeriod publicationDate = VerbatimTimePeriod.NewVerbatimInstance(1999, 2001);
|
114
|
cdDvd.setDatePublished(publicationDate);
|
115
|
|
116
|
//Generic
|
117
|
generic1 = ReferenceFactory.newGeneric();
|
118
|
generic1.setCacheStrategy(defaultStrategy);
|
119
|
genericTeam1 = Team.NewTitledInstance("Authorteam", "AT.");
|
120
|
|
121
|
//WebPage
|
122
|
webPage1 = ReferenceFactory.newWebPage();
|
123
|
webPage1.setCacheStrategy(defaultStrategy);
|
124
|
webPageTeam1 = Team.NewTitledInstance("Authorteam, D.", "AT.");
|
125
|
}
|
126
|
|
127
|
//**************************** TESTS ***********************************
|
128
|
|
129
|
@Test
|
130
|
public void testArticleGetTitleCache(){
|
131
|
journal1.setTitle("My journal");
|
132
|
((Reference)journal1).setAuthorship(articleTeam2); //incorrect use anyway
|
133
|
article1.setTitle("My article");
|
134
|
article1.setInJournal(journal1);
|
135
|
article1.setAuthorship(articleTeam1);
|
136
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
137
|
Assert.assertEquals("Team1, My article in My journal. 1975", article1.getTitleCache());
|
138
|
|
139
|
article1.setInJournal(null);
|
140
|
//TODO should not be needed here
|
141
|
article1.setTitleCache(null, false);
|
142
|
Assert.assertEquals("Team1, My article in " + DefaultReferenceCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
143
|
}
|
144
|
|
145
|
@Test
|
146
|
//This test is just to show that setInJournal(null) now resets caches #1815
|
147
|
public void testArticleGetTitleCache2(){
|
148
|
journal1.setTitle("My journal");
|
149
|
((Reference)journal1).setAuthorship(articleTeam2);
|
150
|
article1.setTitle("My article");
|
151
|
article1.setInJournal(journal1);
|
152
|
article1.setAuthorship(articleTeam1);
|
153
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
154
|
Assert.assertEquals("Team1, My article in My journal. 1975", article1.getTitleCache());
|
155
|
|
156
|
article1.setInJournal(null);
|
157
|
Assert.assertEquals("Team1, My article in " + DefaultReferenceCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
158
|
}
|
159
|
|
160
|
//#6496
|
161
|
@Test
|
162
|
public void testArticleGetTitleCacheWithPages(){
|
163
|
journal1.setTitle("My journal");
|
164
|
((Reference)journal1).setAuthorship(articleTeam2);
|
165
|
article1.setTitle("My article");
|
166
|
article1.setInJournal(journal1);
|
167
|
article1.setAuthorship(articleTeam1);
|
168
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
169
|
Assert.assertEquals("Team1, My article in My journal. 1975", article1.getTitleCache());
|
170
|
article1.setPages("12-22");
|
171
|
Assert.assertEquals("Team1, My article in My journal: 12-22. 1975", article1.getTitleCache());
|
172
|
|
173
|
article1.setVolume("7");
|
174
|
Assert.assertEquals("Team1, My article in My journal 7: 12-22. 1975", article1.getTitleCache());
|
175
|
|
176
|
article1.setSeriesPart("II");
|
177
|
//TODO unclear if punctuation is correct
|
178
|
Assert.assertEquals("Team1, My article in My journal, II, 7: 12-22. 1975", article1.getTitleCache());
|
179
|
}
|
180
|
|
181
|
@Test
|
182
|
public void testArticleGetAbbrevTitleCache(){
|
183
|
|
184
|
journal1.setTitle("My journal");
|
185
|
journal1.setTitle("M. Journ.");
|
186
|
((Reference)journal1).setAuthorship(articleTeam2);
|
187
|
article1.setTitle("My article");
|
188
|
article1.setInJournal(journal1);
|
189
|
article1.setAuthorship(articleTeam1);
|
190
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
191
|
article1.setAbbrevTitle("M. Art.");
|
192
|
Assert.assertEquals("T., M. Art. in M. Journ. 1975", article1.getAbbrevTitleCache()); //double dot may be removed in future #3645
|
193
|
|
194
|
article1.setInJournal(null);
|
195
|
//TODO should not be needed here
|
196
|
article1.setTitleCache(null, false);
|
197
|
Assert.assertEquals("Team1, My article in " + DefaultReferenceCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
198
|
}
|
199
|
|
200
|
@Test
|
201
|
public void testArticleGetNomenclaturalCitation(){
|
202
|
journal1.setTitle("My journal");
|
203
|
journal1.setTitle("M. J.");
|
204
|
((Reference)journal1).setAuthorship(articleTeam2);
|
205
|
article1.setTitle("My article");
|
206
|
article1.setInJournal(journal1);
|
207
|
article1.setAuthorship(articleTeam1);
|
208
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
209
|
Assert.assertEquals("in M. J.: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
210
|
|
211
|
article1.setVolume("22");
|
212
|
Assert.assertEquals("in M. J. 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
213
|
article1.setSeriesPart("ser. 11");
|
214
|
Assert.assertEquals("in M. J., ser. 11, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
215
|
|
216
|
article1.setPages("33"); //#6496 don't show pages in nomencl. citation
|
217
|
Assert.assertEquals("in M. J., ser. 11, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
218
|
}
|
219
|
|
220
|
/**
|
221
|
* After ser. , sect. , abt. we want to have a comma, if there is not yet one following anyway
|
222
|
*/
|
223
|
@Test
|
224
|
public void testArticleGetNomenclaturalCitationSerSectAbt(){
|
225
|
article1.setInJournal(journal1);
|
226
|
article1.setVolume("22");
|
227
|
journal1.setAbbrevTitle("J. Pl. Eur.");
|
228
|
((Reference)journal1).setAuthorship(articleTeam2);
|
229
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
230
|
//no ser, sect, abt
|
231
|
Assert.assertEquals("in J. Pl. Eur. 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
232
|
//ser
|
233
|
journal1.setAbbrevTitle("J. Pl. Eur., ser. 3");
|
234
|
Assert.assertEquals("in J. Pl. Eur., ser. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
235
|
journal1.setAbbrevTitle("J. Pl. Eur., Ser. 3");
|
236
|
Assert.assertEquals("in J. Pl. Eur., Ser. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
237
|
journal1.setAbbrevTitle("J. Pl. Eur., ser. 3, s.n.");
|
238
|
Assert.assertEquals("in J. Pl. Eur., ser. 3, s.n. 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
239
|
//sect
|
240
|
journal1.setAbbrevTitle("J. Pl. Eur., sect. 3");
|
241
|
Assert.assertEquals("in J. Pl. Eur., sect. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
242
|
journal1.setAbbrevTitle("J. Pl. Eur., Sect. 3");
|
243
|
Assert.assertEquals("in J. Pl. Eur., Sect. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
244
|
journal1.setAbbrevTitle("J. Pl. Eur., Sect. 3, something");
|
245
|
Assert.assertEquals("in J. Pl. Eur., Sect. 3, something 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
246
|
//abt
|
247
|
journal1.setAbbrevTitle("J. Pl. Eur., abt. 3");
|
248
|
Assert.assertEquals("in J. Pl. Eur., abt. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
249
|
journal1.setAbbrevTitle("J. Pl. Eur., Abt. 3");
|
250
|
Assert.assertEquals("in J. Pl. Eur., Abt. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
251
|
journal1.setAbbrevTitle("J. Pl. Eur., abt. 3, no comma");
|
252
|
Assert.assertEquals("in J. Pl. Eur., abt. 3, no comma 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
253
|
|
254
|
journal1.setAbbrevTitle("J. Pl. Eur., sect. 3");
|
255
|
article1.setSeriesPart("1");
|
256
|
Assert.assertEquals("in J. Pl. Eur., sect. 3, ser. 1, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
257
|
article1.setSeriesPart("Series 2");
|
258
|
Assert.assertEquals("in J. Pl. Eur., sect. 3, Series 2, 22: 55. 1975", article1.getNomenclaturalCitation(detail1));
|
259
|
}
|
260
|
|
261
|
|
262
|
|
263
|
@Test
|
264
|
public void testArticleGetTitleWithoutYearAndAuthor(){
|
265
|
journal1.setTitle("My journal");
|
266
|
((Reference)journal1).setAuthorship(articleTeam2);
|
267
|
article1.setTitle("My article");
|
268
|
article1.setInJournal(journal1);
|
269
|
article1.setAuthorship(articleTeam1);
|
270
|
article1.setVolume("34");
|
271
|
article1.setSeriesPart("ser. 2");
|
272
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
273
|
//FIXME removed for new formatter
|
274
|
// Assert.assertEquals("in My journal, ser. 2, 34", defaultStrategy.getTitleWithoutYearAndAuthor((Reference)article1, false));
|
275
|
}
|
276
|
|
277
|
@Test
|
278
|
public void testArticleOldExistingBugs(){
|
279
|
journal1.setTitle("Univ. Calif. Publ. Bot.");
|
280
|
((Reference)journal1).setAuthorship(null);
|
281
|
|
282
|
Team articleAuthor = Team.NewTitledInstance("Babc. & Stebbins", "Babc. & Stebbins");
|
283
|
article1.setTitle("");
|
284
|
article1.setInJournal(journal1);
|
285
|
article1.setAuthorship(articleAuthor);
|
286
|
article1.setVolume("18");
|
287
|
article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1943));
|
288
|
Assert.assertEquals("Babc. & Stebbins in Univ. Calif. Publ. Bot. 18. 1943", defaultStrategy.getTitleCache((Reference)article1));
|
289
|
}
|
290
|
|
291
|
// ******************* Book ****************************/
|
292
|
|
293
|
@Test
|
294
|
public void testBookGetTitleCache0(){
|
295
|
book1.setTitle("My book");
|
296
|
book1.setAuthorship(bookTeam1);
|
297
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
298
|
Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
|
299
|
|
300
|
book1.setTitleCache(null, false);
|
301
|
book1.setEdition("ed. 3");
|
302
|
Assert.assertEquals("Unexpected title cache.", "Book Author, My book, ed. 3. 1975", book1.getTitleCache());
|
303
|
|
304
|
VerbatimTimePeriod newDatePublished = TimePeriodParser.parseStringVerbatim("1975 (after Aug.)");
|
305
|
book1.setDatePublished(newDatePublished);
|
306
|
book1.setTitleCache(null, false);
|
307
|
//TODO this behaviour needs to be discussed. Maybe better the complete date published string should be returned.
|
308
|
Assert.assertEquals("Unexpected title cache.", "Book Author, My book, ed. 3", book1.getTitleCache());
|
309
|
|
310
|
book1.setPages("1-405");
|
311
|
Assert.assertEquals("Unexpected title cache.", "Book Author, My book, ed. 3: 1-405", book1.getTitleCache());
|
312
|
|
313
|
}
|
314
|
|
315
|
//https://dev.e-taxonomy.eu/redmine/issues/8881
|
316
|
@Test
|
317
|
public void testInRefAuthor(){
|
318
|
Person person1 = Person.NewInstance("Inauth.", "Inauthor", "A.B.", "Ala Bala");
|
319
|
Person person2 = Person.NewInstance("Twoauth.", "Twoauthor", "C.", "Cla");
|
320
|
Person person3 = Person.NewTitledInstance("Threeauth.");
|
321
|
Team team = Team.NewInstance(person1, person2, person3);
|
322
|
IBook book1 = ReferenceFactory.newBook();
|
323
|
book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
|
324
|
book1.setVolume("Fasc. 11");
|
325
|
book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
|
326
|
bookSection1.setTitle("My chapter");
|
327
|
bookSection1.setInBook(book1);
|
328
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1956));
|
329
|
|
330
|
book1.setAuthorship(person1);
|
331
|
Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
332
|
book1.setAuthorship(team);
|
333
|
Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Twoauthor & Threeauth., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
334
|
team.setHasMoreMembers(true);
|
335
|
Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Twoauthor, Threeauth. & al., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
336
|
book1.setAuthorship(Team.NewInstance(person1));
|
337
|
Assert.assertEquals("Unexpected nomencl. reference", "in Inauthor, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
338
|
|
339
|
//for the following the behavior is not yet finally discussed, may change in future
|
340
|
book1.setAuthorship(team);
|
341
|
team.setTitleCache("Teamcache", true);
|
342
|
Assert.assertEquals("Unexpected nomencl. reference", "in Teamcache, Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
343
|
team.setTitleCache("Teamc.", true);
|
344
|
Assert.assertEquals("Unexpected nomencl. reference", "in Teamc., Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
345
|
book1.setAuthorship(Team.NewInstance());
|
346
|
Assert.assertEquals("Unexpected nomencl. reference", "in "+TeamDefaultCacheStrategy.EMPTY_TEAM+", Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1956", bookSection1.getNomenclaturalCitation("248"));
|
347
|
}
|
348
|
|
349
|
@Test
|
350
|
public void testBookGetTitleCache1(){
|
351
|
//series
|
352
|
IBook book1 = ReferenceFactory.newBook();
|
353
|
book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
|
354
|
book1.setSeriesPart("1");
|
355
|
book1.setVolume("Fasc. 11");
|
356
|
book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
|
357
|
Assert.assertEquals("Unexpected abbrev title cache", "Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11. 1955", book1.getTitleCache());
|
358
|
Assert.assertEquals("Unexpected nomencl. reference", "Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11: 248. 1955", book1.getNomenclaturalCitation("248"));
|
359
|
}
|
360
|
|
361
|
@Test
|
362
|
public void testBookGetTitleCache2(){
|
363
|
//series
|
364
|
IBook book1 = ReferenceFactory.newBook();
|
365
|
book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
|
366
|
book1.setVolume("Fasc. 11");
|
367
|
book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
|
368
|
Assert.assertEquals("Unexpected abbrev title cache", "Acta Inst. Bot. Acad. Sci. URSS Fasc. 11. 1955", book1.getTitleCache());
|
369
|
Assert.assertEquals("Unexpected nomencl. reference", "Acta Inst. Bot. Acad. Sci. URSS Fasc. 11: 248. 1955", book1.getNomenclaturalCitation("248"));
|
370
|
book1.setSeriesPart("1");
|
371
|
Assert.assertEquals("Unexpected nomencl. reference", "Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11: 248. 1955", book1.getNomenclaturalCitation("248"));
|
372
|
}
|
373
|
|
374
|
@Test
|
375
|
public void testBookGetNomenclaturalCitation(){
|
376
|
book1.setTitle("My book");
|
377
|
book1.setAuthorship(bookTeam1);
|
378
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
379
|
Assert.assertEquals("My book: 55. 1975", book1.getNomenclaturalCitation(detail1));
|
380
|
book1.setAbbrevTitle("Analect. Bot.");
|
381
|
Assert.assertEquals("Analect. Bot. 1975", book1.getNomenclaturalCitation(null));
|
382
|
}
|
383
|
|
384
|
// ***************************** Book Section ************************/
|
385
|
|
386
|
@Test
|
387
|
public void testBookSectionGetTitleCache(){
|
388
|
book1.setTitle("My book");
|
389
|
book1.setAuthorship(bookTeam1);
|
390
|
bookSection1.setTitle("My chapter");
|
391
|
bookSection1.setInBook(book1);
|
392
|
bookSection1.setAuthorship(sectionTeam1);
|
393
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
394
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1975", bookSection1.getTitleCache());
|
395
|
book1.setDatePublished((VerbatimTimePeriod)null);
|
396
|
bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
|
397
|
bookSection1.setTitleCache(null, false);
|
398
|
book1.setTitleCache(null, false);
|
399
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache());
|
400
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
|
401
|
bookSection1.setTitleCache(null, false);
|
402
|
book1.setTitleCache(null, false);
|
403
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache());
|
404
|
bookSection1.setTitleCache(null, false);
|
405
|
book1.setTitleCache(null, false);
|
406
|
book1.setSeriesPart("2");
|
407
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache());
|
408
|
|
409
|
//FIXME #6496
|
410
|
// bookSection1.setPages("33-38");
|
411
|
// bookSection1.setTitleCache(null);
|
412
|
// Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book, ser. 2: 33-38. 1976", bookSection1.getTitleCache());
|
413
|
|
414
|
bookSection1.setInBook(null);
|
415
|
bookSection1.setTitleCache(null, false);
|
416
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in - undefined book -. 1976", bookSection1.getTitleCache());
|
417
|
|
418
|
}
|
419
|
|
420
|
@Test
|
421
|
//This test is just to show that setInBook(null) now resets caches #1815
|
422
|
public void testBookSectionGetTitleCache2(){
|
423
|
book1.setTitle("My book");
|
424
|
book1.setAuthorship(bookTeam1);
|
425
|
bookSection1.setTitle("My chapter");
|
426
|
bookSection1.setInBook(book1);
|
427
|
bookSection1.setAuthorship(sectionTeam1);
|
428
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
429
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1975", bookSection1.getTitleCache());
|
430
|
book1.setDatePublished((VerbatimTimePeriod)null);
|
431
|
bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
|
432
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache());
|
433
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
|
434
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in Book Author, My book. 1976", bookSection1.getTitleCache());
|
435
|
|
436
|
|
437
|
bookSection1.setInBook(null);
|
438
|
Assert.assertEquals("Unexpected title cache.", "Section Author - My chapter in - undefined book -. 1976", bookSection1.getTitleCache());
|
439
|
|
440
|
}
|
441
|
|
442
|
|
443
|
@Test
|
444
|
public void testBookSectionGetNomenclaturalCitation(){
|
445
|
book1.setTitle("My book");
|
446
|
book1.setAuthorship(bookTeam1);
|
447
|
bookSection1.setTitle("My chapter");
|
448
|
bookSection1.setInBook(book1);
|
449
|
bookSection1.setAuthorship(sectionTeam1);
|
450
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
451
|
//TODO still unclear which is correct
|
452
|
// Assert.assertEquals("in Book Author, My book: 55. 1975", bookSection1.getNomenclaturalCitation(detail1));
|
453
|
Assert.assertEquals("in TT., My book: 55. 1975", bookSection1.getNomenclaturalCitation(detail1));
|
454
|
|
455
|
book1.setSeriesPart("2");
|
456
|
Assert.assertEquals("in TT., My book, ser. 2: 55. 1975", bookSection1.getNomenclaturalCitation(detail1));
|
457
|
//#6496 don't show pages in nom.ref. citations
|
458
|
bookSection1.setPages("35-39");
|
459
|
Assert.assertEquals("in TT., My book, ser. 2: 55. 1975", bookSection1.getNomenclaturalCitation(detail1));
|
460
|
|
461
|
}
|
462
|
|
463
|
@Test
|
464
|
public void testBookSectionRealExample(){
|
465
|
Team bookTeam = Team.NewTitledInstance("Chaudhary S. A.(ed.)", "Chaudhary S. A.(ed.)");
|
466
|
IBook book = ReferenceFactory.newBook();
|
467
|
book.setTitle("Flora of the Kingdom of Saudi Arabia");
|
468
|
book.setAuthorship(bookTeam);
|
469
|
book.setVolume("2(3)");
|
470
|
book.setPlacePublished("Riyadh");
|
471
|
book.setPublisher("National Herbarium");
|
472
|
book.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(2000));
|
473
|
|
474
|
Team sectionTeam = Team.NewTitledInstance("Chaudhary S. A.", "Chaudhary S. A.");
|
475
|
IBookSection bookSection = ReferenceFactory.newBookSection();
|
476
|
bookSection.setTitle("73. Hedypnois - 87. Crepis");
|
477
|
bookSection.setInBook(book);
|
478
|
bookSection.setAuthorship(sectionTeam);
|
479
|
bookSection.setPages("222-251");
|
480
|
Assert.assertEquals("Chaudhary S. A. - 73. Hedypnois - 87. Crepis in Chaudhary S. A.(ed.), Flora of the Kingdom of Saudi Arabia 2(3). 2000", bookSection.getTitleCache());
|
481
|
|
482
|
}
|
483
|
|
484
|
@Test
|
485
|
public void testCdDvdGetTitleWithoutYearAndAuthor() {
|
486
|
String result = TitleWithoutYearAndAuthorHelper.getTitleWithoutYearAndAuthor(cdDvd, false);
|
487
|
assertEquals(cdDvdTitle, result);
|
488
|
}
|
489
|
|
490
|
//TODO missing publicationPlace and publisher has to be discussed
|
491
|
@Test
|
492
|
public void testCdDvdGetTitleCache() {
|
493
|
String result = defaultStrategy.getTitleCache(cdDvd);
|
494
|
assertEquals(cdDvdTitle + ". 1999"+SEP+"2001", result);
|
495
|
}
|
496
|
|
497
|
// *************************** GENERIC *****************************************/
|
498
|
|
499
|
@Test
|
500
|
public void testGenericGetTitleCache(){
|
501
|
generic1.setTitle("auct.");
|
502
|
Assert.assertEquals("Unexpected title cache.", "auct.", generic1.getTitleCache());
|
503
|
}
|
504
|
|
505
|
@Test
|
506
|
public void testGenericGetInRef(){
|
507
|
generic1.setTitle("auct.");
|
508
|
IBook book1 = ReferenceFactory.newBook();
|
509
|
book1.setTitle("My book title");
|
510
|
book1.setAuthorship(genericTeam1);
|
511
|
Reference inRef = (Reference)book1;
|
512
|
generic1.setInReference(inRef);
|
513
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
514
|
//TODO author still unclear
|
515
|
// Assert.assertEquals("Unexpected title cache.", "in Authorteam, My book title: 2", generic1.getNomenclaturalCitation("2"));
|
516
|
Assert.assertEquals("Unexpected title cache.", "in AT., My book title: 2", generic1.getNomenclaturalCitation("2"));
|
517
|
}
|
518
|
|
519
|
@Test
|
520
|
public void testGenericGetInRefWithoutInRef(){
|
521
|
generic1.setTitle("My generic title");
|
522
|
generic1.setAuthorship(genericTeam1);
|
523
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
524
|
Assert.assertEquals("Unexpected title cache.", "My generic title: 2", generic1.getNomenclaturalCitation("2"));
|
525
|
}
|
526
|
|
527
|
@Test
|
528
|
public void testGenericGetTitleCache2(){
|
529
|
generic1.setTitle("Part Title");
|
530
|
IBook book1 = ReferenceFactory.newBook();
|
531
|
book1.setTitle("My book title");
|
532
|
book1.setAuthorship(genericTeam1);
|
533
|
Reference inRef = (Reference)book1;
|
534
|
generic1.setInReference(inRef);
|
535
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
536
|
Assert.assertEquals("Unexpected title cache.", "Part Title in Authorteam, My book title", generic1.getTitleCache());
|
537
|
}
|
538
|
|
539
|
|
540
|
@Test
|
541
|
public void testGenericGetAbbrevTitleCache(){
|
542
|
generic1.setTitle("Part Title");
|
543
|
generic1.setAbbrevTitle("Pt. Tit.");
|
544
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1987"));
|
545
|
IBook book1 = ReferenceFactory.newBook();
|
546
|
book1.setTitle("My book title");
|
547
|
book1.setAbbrevTitle("My bk. tit.");
|
548
|
book1.setAuthorship(genericTeam1); //TODO handling not yet defined
|
549
|
Reference inRef = (Reference)book1;
|
550
|
generic1.setInReference(inRef);
|
551
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
552
|
generic1.setAbbrevTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
553
|
Assert.assertEquals("Unexpected abbrev title cache.", "Pt. Tit. in AT., My bk. tit. 1987", generic1.getAbbrevTitleCache());
|
554
|
Assert.assertEquals("Title cache must still be the same", "Part Title in Authorteam, My book title. 1987", generic1.getTitleCache());
|
555
|
//TODO author still unclear
|
556
|
// Assert.assertEquals("Unexpected nom. ref.", "in Authorteam, My bk. tit.: pp. 44. 1987", generic1.getNomenclaturalCitation("pp. 44"));
|
557
|
Assert.assertEquals("Unexpected nom. ref.", "in AT., My bk. tit.: pp. 44. 1987", generic1.getNomenclaturalCitation("pp. 44"));
|
558
|
generic1.setVolume("23");
|
559
|
Assert.assertEquals("Unexpected nom. ref.", "in AT., My bk. tit. 23: pp. 44. 1987", generic1.getNomenclaturalCitation("pp. 44"));
|
560
|
generic1.setSeriesPart("ser. 11");
|
561
|
//TODO
|
562
|
// Assert.assertEquals("Unexpected nom. ref.", "in AT., My bk. tit., ser. 11, 23: pp. 44. 1987", generic1.getNomenclaturalCitation("pp. 44"));
|
563
|
|
564
|
|
565
|
//protected
|
566
|
generic1.setAbbrevTitleCache("My prot. abb. tit. in a bk.", true);
|
567
|
Assert.assertEquals("Unexpected abbrev title cache.", "My prot. abb. tit. in a bk.", generic1.getAbbrevTitleCache());
|
568
|
Assert.assertEquals("Unexpected title cache.", "Part Title in Authorteam, My book title. 1987", generic1.getTitleCache());
|
569
|
|
570
|
generic1.setDatePublished((VerbatimTimePeriod)null);
|
571
|
Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.", generic1.getNomenclaturalCitation(null));
|
572
|
Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.", generic1.getNomenclaturalCitation(""));
|
573
|
Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.: pp. 44", generic1.getNomenclaturalCitation("pp. 44"));
|
574
|
|
575
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1893"));
|
576
|
Assert.assertEquals("Unexpected nom. ref.", "My prot. abb. tit. in a bk.: pp. 44. 1893", generic1.getNomenclaturalCitation("pp. 44"));
|
577
|
|
578
|
}
|
579
|
|
580
|
@Test
|
581
|
public void testGenericGetTitleCacheWithoutInRef(){
|
582
|
generic1.setTitle("My generic title");
|
583
|
generic1.setAuthorship(genericTeam1);
|
584
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
585
|
Assert.assertEquals("Unexpected title cache.", "Authorteam, My generic title", generic1.getTitleCache());
|
586
|
}
|
587
|
|
588
|
@Test
|
589
|
public void testGenericAuthorOnly(){
|
590
|
generic1.setAuthorship(genericTeam1);
|
591
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
592
|
Assert.assertEquals("Unexpected title cache.", "Authorteam", generic1.getTitleCache());
|
593
|
Assert.assertEquals("", generic1.getNomenclaturalCitation(null));
|
594
|
}
|
595
|
|
596
|
@Test
|
597
|
public void testGenericYearAndAuthorOnly(){
|
598
|
generic1.setAuthorship(genericTeam1);
|
599
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1792"));
|
600
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
601
|
Assert.assertEquals("Unexpected title cache.", "Authorteam, 1792", generic1.getTitleCache());
|
602
|
Assert.assertEquals("1792", generic1.getNomenclaturalCitation(null));
|
603
|
}
|
604
|
|
605
|
@Test
|
606
|
public void testGenericDoubleDotBeforeYear(){
|
607
|
generic1.setAuthorship(genericTeam1);
|
608
|
String detail = "sine no.";
|
609
|
generic1.setAbbrevTitle("My title");
|
610
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1883-1884"));
|
611
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
612
|
Assert.assertEquals("My title: sine no. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail));
|
613
|
}
|
614
|
|
615
|
//#4338
|
616
|
@Test
|
617
|
public void testGenericMissingVolume(){
|
618
|
generic1.setTitle("My generic");
|
619
|
generic1.setAuthorship(genericTeam1);
|
620
|
generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1883-1884"));
|
621
|
generic1.setTitleCache(null, false); //reset cache in case aspectJ is not enabled
|
622
|
Assert.assertEquals("My generic: 55. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail1));
|
623
|
generic1.setVolume("7");
|
624
|
Assert.assertEquals("My generic 7: 55. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail1));
|
625
|
Assert.assertEquals("Authorteam, My generic 7. 1883"+SEP+"1884", generic1.getTitleCache());
|
626
|
Assert.assertEquals("AT., My generic 7. 1883"+SEP+"1884", generic1.getAbbrevTitleCache());
|
627
|
|
628
|
//inRef
|
629
|
Reference generic2 = ReferenceFactory.newGeneric();
|
630
|
generic2.setTitle("My InRef");
|
631
|
Person person2 = Person.NewTitledInstance("InRefAuthor");
|
632
|
generic2.setAuthorship(person2);
|
633
|
generic2.setDatePublished(TimePeriodParser.parseStringVerbatim("1885"));
|
634
|
generic1.setInReference(generic2);
|
635
|
|
636
|
//only reference has a volume
|
637
|
Assert.assertEquals("in InRefAuthor, My InRef 7: 55. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail1));
|
638
|
// Assert.assertEquals("Authorteam - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getTitleCache());
|
639
|
// Assert.assertEquals("AT. - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getAbbrevTitleCache());
|
640
|
|
641
|
//both have a volume
|
642
|
generic2.setVolume("9"); //still unclear what should happen if you have such dirty data
|
643
|
// Assert.assertEquals("in InRefAuthor, My InRef 7: 55. 1883-1884", generic1.getNomenclaturalCitation(detail1));
|
644
|
// Assert.assertEquals("Authorteam - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getTitleCache());
|
645
|
// Assert.assertEquals("AT. - My generic in InRefAuthor, My InRef 7. 1883-1884", generic1.getAbbrevTitleCache());
|
646
|
|
647
|
//only inref has volume
|
648
|
generic1.setVolume(null);
|
649
|
Assert.assertEquals("in InRefAuthor, My InRef 9: 55. 1883"+SEP+"1884", generic1.getNomenclaturalCitation(detail1));
|
650
|
Assert.assertEquals("Authorteam - My generic in InRefAuthor, My InRef 9. 1883"+SEP+"1884", generic1.getTitleCache());
|
651
|
Assert.assertEquals("AT. - My generic in InRefAuthor, My InRef 9. 1883"+SEP+"1884", generic1.getAbbrevTitleCache());
|
652
|
}
|
653
|
|
654
|
//#3532
|
655
|
@Test
|
656
|
public void testUnexpectedNomenclaturalReferences(){
|
657
|
Reference reference;
|
658
|
|
659
|
//database
|
660
|
IDatabase database1 = ReferenceFactory.newDatabase();
|
661
|
reference = (Reference)database1;
|
662
|
|
663
|
database1.setTitle("My database");
|
664
|
//maybe we should have a trailing dot here
|
665
|
Assert.assertEquals("My database: 55", reference.getNomenclaturalCitation(detail1));
|
666
|
database1.setDatePublished(TimePeriodParser.parseStringVerbatim("1998"));
|
667
|
Assert.assertEquals("My database: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
668
|
|
669
|
database1.setTitleCache("Your database", true);
|
670
|
Assert.assertEquals("My database: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
671
|
|
672
|
//unclear if it is wanted that the year is shown, though the abbrev cache is protected, probably not
|
673
|
reference.setAbbrevTitleCache("You. Db.", true);
|
674
|
Assert.assertEquals("You. Db.: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
675
|
|
676
|
|
677
|
//CD/DVD
|
678
|
ICdDvd cdDvd = ReferenceFactory.newCdDvd();
|
679
|
reference= (Reference)cdDvd;
|
680
|
cdDvd.setTitle("My Cd/Dvd");
|
681
|
//maybe we should have a trailing dot here
|
682
|
Assert.assertEquals("My Cd/Dvd: 55", reference.getNomenclaturalCitation(detail1));
|
683
|
cdDvd.setDatePublished(TimePeriodParser.parseStringVerbatim("1998"));
|
684
|
Assert.assertEquals("My Cd/Dvd: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
685
|
|
686
|
cdDvd.setTitleCache("Your Cd/Dvd", true);
|
687
|
Assert.assertEquals("My Cd/Dvd: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
688
|
|
689
|
//unclear if it is wanted that the year is shown, though the abbrev cache is protected, probably not
|
690
|
reference.setAbbrevTitleCache("You. Cd.", true);
|
691
|
Assert.assertEquals("You. Cd.: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
692
|
|
693
|
|
694
|
//WebSite
|
695
|
IWebPage webPage = ReferenceFactory.newWebPage();
|
696
|
reference= (Reference)webPage;
|
697
|
webPage.setTitle("My WebPage");
|
698
|
//maybe we should have a trailing dot here
|
699
|
Assert.assertEquals("My WebPage: 55", reference.getNomenclaturalCitation(detail1));
|
700
|
webPage.setDatePublished(TimePeriodParser.parseStringVerbatim("1998"));
|
701
|
Assert.assertEquals("My WebPage: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
702
|
|
703
|
webPage.setTitleCache("Your WebPage", true);
|
704
|
Assert.assertEquals("My WebPage: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
705
|
|
706
|
//unclear if it is wanted that the year is shown, though the abbrev cache is protected, probably not
|
707
|
reference.setAbbrevTitleCache("You. WP.", true);
|
708
|
Assert.assertEquals("You. WP.: 55. 1998", reference.getNomenclaturalCitation(detail1));
|
709
|
|
710
|
//uri
|
711
|
webPage = ReferenceFactory.newWebPage();
|
712
|
reference= (Reference)webPage;
|
713
|
webPage.setUri(URI.create("http://www.abc.de"));
|
714
|
Assert.assertEquals("http://www.abc.de: 55", reference.getNomenclaturalCitation(detail1));
|
715
|
|
716
|
//TBC
|
717
|
}
|
718
|
|
719
|
// ********************************** WEB PAGE ********************************************/
|
720
|
|
721
|
@Test
|
722
|
//still preliminary, may be modified in future
|
723
|
public void testWebPageGetTitleCache(){
|
724
|
webPage1.setUri(URI.create("http://flora.huji.ac.il"));
|
725
|
Assert.assertEquals("Unexpected title cache.",
|
726
|
"http://flora.huji.ac.il",
|
727
|
webPage1.getTitleCache());
|
728
|
|
729
|
webPage1.setTitle("Flora of Israel Online");
|
730
|
webPage1.setAuthorship(webPageTeam1);
|
731
|
webPage1.setAccessed(DateTime.parse("2001-01-05"));
|
732
|
Assert.assertEquals("Unexpected title cache.",
|
733
|
"Authorteam, D., Flora of Israel Online - http://flora.huji.ac.il [accessed 2001-01-05]",
|
734
|
webPage1.getTitleCache());
|
735
|
}
|
736
|
|
737
|
// @Test
|
738
|
// //WebPages should usually not be used as nomencl.reference, therefore this is less important
|
739
|
// public void testWebPageGetAbbrevTitleCache(){
|
740
|
// webPage1.setTitle("auct.");
|
741
|
// Assert.assertEquals("Unexpected title cache.", "auct.", webPage1.getTitleCache());
|
742
|
// }
|
743
|
|
744
|
@Test
|
745
|
public void testCreateShortCitation(){
|
746
|
book1.setTitle("My book");
|
747
|
book1.setAuthorship(bookTeam1);
|
748
|
book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
|
749
|
Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
|
750
|
|
751
|
book1.setTitleCache(null, false);
|
752
|
book1.setEdition("ed. 3");
|
753
|
|
754
|
Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, null, false));
|
755
|
Assert.assertEquals("Unexpected title cache.", "Book Author 1975", book1.getCacheStrategy().createShortCitation((Reference)book1, "", false));
|
756
|
Assert.assertEquals("Unexpected title cache.", "Book Author 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
757
|
Assert.assertEquals("Unexpected title cache.", "Book Author (1975: 55)", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", true));
|
758
|
|
759
|
//1 person
|
760
|
Person person1 = Person.NewInstance("Pers.", "Person", "P.", "Percy");
|
761
|
Team team = Team.NewInstance(person1);
|
762
|
book1.setAuthorship(team);
|
763
|
Assert.assertEquals("Unexpected title cache.", "Person 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
764
|
team.setHasMoreMembers(true);
|
765
|
Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
766
|
team.setHasMoreMembers(false);
|
767
|
|
768
|
//2 persons
|
769
|
Person person2 = Person.NewInstance("Lers.", "Lerson", "L.", "Lercy");
|
770
|
team.addTeamMember(person2);
|
771
|
Assert.assertEquals("Unexpected title cache.", "Person & Lerson 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
772
|
team.setHasMoreMembers(true);
|
773
|
Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
774
|
team.setHasMoreMembers(false);
|
775
|
|
776
|
//3 persons
|
777
|
Person person3 = Person.NewInstance("Gers.", "Gerson", "G.", "Gercy");
|
778
|
team.addTeamMember(person3);
|
779
|
Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
780
|
team.setHasMoreMembers(true);
|
781
|
Assert.assertEquals("Unexpected title cache.", "Person & al. 1975: 55", book1.getCacheStrategy().createShortCitation((Reference)book1, "55", false));
|
782
|
team.setHasMoreMembers(false); //in case we want to continue test
|
783
|
|
784
|
|
785
|
}
|
786
|
|
787
|
}
|