Project

General

Profile

« Previous | Next » 

Revision 9d4f868a

Added by Andreas Müller almost 3 years ago

ref #1924 put year after author in bibliographic references and separate with colon

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ReferenceDefaultCacheStrategyTest.java
77 77

  
78 78
	//common
79 79
	private static ReferenceDefaultCacheStrategy defaultStrategy;
80
	private static final String detail1 = "55";
81 80

  
82 81
	@BeforeClass
83 82
	public static void setUpBeforeClass() throws Exception {
......
136 135
		article1.setInJournal(journal1);
137 136
		article1.setAuthorship(articleTeam1);
138 137
		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
139
		Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal. 1975", article1.getTitleCache());
138
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
140 139

  
141 140
		article1.setInJournal(null);
142
		//TODO should not be needed here
143
		article1.setTitleCache(null, false);
144
		Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
141
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
145 142
	}
146 143

  
147 144
	@Test
......
153 150
		article1.setInJournal(journal1);
154 151
		article1.setAuthorship(articleTeam1);
155 152
		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
156
		Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal. 1975", article1.getTitleCache());
153
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
157 154

  
158 155
		article1.setInJournal(null);
159
		Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
156
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
160 157
        article1.setDatePublished(null);
161
        Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL, article1.getTitleCache());
158
        Assert.assertEquals("Team1: My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ".", article1.getTitleCache());
162 159
	}
163 160

  
164 161
	//#6496
......
170 167
        article1.setInJournal(journal1);
171 168
        article1.setAuthorship(articleTeam1);
172 169
        article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
173
        Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal. 1975", article1.getTitleCache());
170
        Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal.", article1.getTitleCache());
174 171
        article1.setPages("12-22");
175
        Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal: 12-22. 1975", article1.getTitleCache());
172
        Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal: 12-22.", article1.getTitleCache());
176 173

  
177 174
        article1.setVolume("7");
178
        Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal 7: 12-22. 1975", article1.getTitleCache());
175
        Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal 7: 12-22.", article1.getTitleCache());
179 176

  
180 177
        article1.setSeriesPart("II");
181 178
        //TODO unclear if punctuation is correct
182
        Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" My journal, II, 7: 12-22. 1975", article1.getTitleCache());
179
        Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH+" My journal, II, 7: 12-22.", article1.getTitleCache());
183 180
   }
184 181

  
185 182
	@Test
......
193 190
		article1.setAuthorship(articleTeam1);
194 191
		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
195 192
		article1.setAbbrevTitle("M. Art.");
196
		Assert.assertEquals("T., M. Art. "+UTF8.EN_DASH+" M. Journ. 1975", article1.getAbbrevTitleCache());  //double dot may be removed in future #3645
193
		Assert.assertEquals("T. 1975: M. Art. "+UTF8.EN_DASH+" M. Journ.", article1.getAbbrevTitleCache());
194
		article1.setVolume("7");
195
        Assert.assertEquals("T. 1975: M. Art. "+UTF8.EN_DASH+" M. Journ. 7.", article1.getAbbrevTitleCache());
197 196

  
198 197
		article1.setInJournal(null);
199 198
		article1.setTitleCache(null, false);
200
		Assert.assertEquals("Team1, My article. "+UTF8.EN_DASH+" " + ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
199
		Assert.assertEquals("Team1 1975: My article. "+UTF8.EN_DASH + " " +ReferenceDefaultCacheStrategy.UNDEFINED_JOURNAL + " 7.", article1.getTitleCache());
201 200
	}
202 201

  
203 202
	@Test
......
231 230
		article1.setAuthorship(articleAuthor);
232 231
		article1.setVolume("18");
233 232
		article1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1943));
234
		//TODO what is the correct separator here? #9529
235
		Assert.assertEquals("Babc. & Stebbins "+UTF8.EN_DASH+" Univ. Calif. Publ. Bot. 18. 1943", defaultStrategy.getTitleCache((Reference)article1));
233
		Assert.assertEquals("Babc. & Stebbins 1943: "+UTF8.EN_DASH+" Univ. Calif. Publ. Bot. 18.", defaultStrategy.getTitleCache((Reference)article1));
236 234
	}
237 235

  
238 236
// ******************* Book ****************************/
......
242 240
        book1.setTitle("My book");
243 241
        book1.setAuthorship(bookTeam1);
244 242
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
245
        Assert.assertEquals("Unexpected title cache.", "Book Author, My book. 1975", book1.getTitleCache());
243
        Assert.assertEquals("Unexpected title cache.", "Book Author 1975: My book.", book1.getTitleCache());
246 244

  
247 245
        book1.setTitleCache(null, false);
248 246
        book1.setEdition("ed. 3");
249
        Assert.assertEquals("Unexpected title cache.", "Book Author, My book, ed. 3. 1975", book1.getTitleCache());
247
        Assert.assertEquals("Unexpected title cache.", "Book Author 1975: My book, ed. 3.", book1.getTitleCache());
250 248

  
251 249
        VerbatimTimePeriod newDatePublished = TimePeriodParser.parseStringVerbatim("1975 (after Aug.)");
252 250
        book1.setDatePublished(newDatePublished);
253 251
        book1.setTitleCache(null, false);
254 252
        //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());
253
        Assert.assertEquals("Unexpected title cache.", "Book Author: My book, ed. 3.", book1.getTitleCache());
256 254

  
257 255
        book1.setPages("1-405");
258
        Assert.assertEquals("Unexpected title cache.", "Book Author, My book, ed. 3: 1-405", book1.getTitleCache());
256
        Assert.assertEquals("Unexpected title cache.", "Book Author: My book, ed. 3: 1-405.", book1.getTitleCache());
259 257

  
260 258
    }
261 259

  
......
266 264
        book1.setAbbrevTitle("Acta Inst. Bot. Acad. Sci. URSS");
267 265
        book1.setVolume("Fasc. 11");
268 266
        book1.setDatePublished(TimePeriodParser.parseStringVerbatim("1955"));
269
        Assert.assertEquals("Unexpected abbrev title cache", "Acta Inst. Bot. Acad. Sci. URSS Fasc. 11. 1955", book1.getTitleCache());
267
        //TODO needs to be discussed
268
        Assert.assertEquals("Unexpected abbrev title cache", "1955: Acta Inst. Bot. Acad. Sci. URSS Fasc. 11.", book1.getTitleCache());
270 269
        book1.setSeriesPart("1");
271
        Assert.assertEquals("Unexpected abbrev title cache", "Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11. 1955", book1.getTitleCache());
270
        //TODO needs to be discussed
271
        Assert.assertEquals("Unexpected abbrev title cache", "1955: Acta Inst. Bot. Acad. Sci. URSS, ser. 1, Fasc. 11.", book1.getTitleCache());
272 272
    }
273 273

  
274 274
// ***************************** Book Section ************************/
......
283 283
        bookSection1.setInBook(book1);
284 284
        bookSection1.setAuthorship(sectionTeam1);
285 285
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
286
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1975", bookSection1.getTitleCache());
286
        Assert.assertEquals("Unexpected title cache.", "Section Author 1975: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
287 287

  
288 288
        book1.setDatePublished((VerbatimTimePeriod)null);
289 289
        bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
290 290
        bookSection1.setTitleCache(null, false);
291 291
        book1.setTitleCache(null, false);
292
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1976", bookSection1.getTitleCache());
292
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
293 293
        //with in-ref year (ignore if there is ref year)
294 294
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
295 295
        bookSection1.setTitleCache(null, false);
296 296
        book1.setTitleCache(null, false);
297
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1976", bookSection1.getTitleCache());
297
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
298 298
        //with series part
299 299
        bookSection1.setTitleCache(null, false);
300 300
        book1.setTitleCache(null, false);
301 301
        book1.setSeriesPart("2");
302
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache());
302
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
303 303
        //without section title
304 304
        bookSection1.setTitle(null);
305 305
        bookSection1.setTitleCache(null, false);
306 306
        book1.setTitleCache(null, false);
307
        Assert.assertEquals("Unexpected title cache.", "Section Author "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache());
307
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976 "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
308 308
        bookSection1.setTitle(bookSetionTitle);
309 309

  
310 310
        //#6496, 9529, 9530
311 311
        bookSection1.setPages("33-38");
312 312
        bookSection1.setTitleCache(null, false);
313
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter, pp. 33-38. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache());
313
        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());
314 314
        bookSection1.setPages("v");
315 315
        bookSection1.setTitleCache(null, false);
316
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter, p. v. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2. 1976", bookSection1.getTitleCache());
316
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter, p. v. "+UTF8.EN_DASH+" In: Book Author, My book, ser. 2.", bookSection1.getTitleCache());
317 317
        bookSection1.setPages(null);
318 318

  
319 319
        bookSection1.setInBook(null);
320 320
        bookSection1.setTitleCache(null, false);
321
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: - undefined book -. 1976", bookSection1.getTitleCache());
321
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: - undefined book -.", bookSection1.getTitleCache());
322 322
    }
323 323

  
324 324
    @Test
......
330 330
        bookSection1.setInBook(book1);
331 331
        bookSection1.setAuthorship(sectionTeam1);
332 332
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1975));
333
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1975", bookSection1.getTitleCache());
333
        Assert.assertEquals("Unexpected title cache.", "Section Author 1975: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
334 334
        book1.setDatePublished((VerbatimTimePeriod)null);
335 335
        bookSection1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1976));
336
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1976", bookSection1.getTitleCache());
336
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
337 337
        book1.setDatePublished(VerbatimTimePeriod.NewVerbatimInstance(1977));
338
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book. 1976", bookSection1.getTitleCache());
338
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: Book Author, My book.", bookSection1.getTitleCache());
339 339

  
340 340
        bookSection1.setInBook(null);
341
        Assert.assertEquals("Unexpected title cache.", "Section Author: My chapter. "+UTF8.EN_DASH+" In: - undefined book -. 1976", bookSection1.getTitleCache());
341
        Assert.assertEquals("Unexpected title cache.", "Section Author 1976: My chapter. "+UTF8.EN_DASH+" In: - undefined book -.", bookSection1.getTitleCache());
342 342
    }
343 343

  
344 344
    @Test
......
358 358
        bookSection.setInBook(book);
359 359
        bookSection.setAuthorship(sectionTeam);
360 360
        bookSection.setPages("222-251");
361
        Assert.assertEquals("Chaudhary S. A.: 73. Hedypnois - 87. Crepis, pp. 222-251. "+UTF8.EN_DASH+" In: Chaudhary S. A.(ed.), Flora of the Kingdom of Saudi Arabia 2(3). 2000", bookSection.getTitleCache());
361
        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());
362 362

  
363 363
    }
364 364

  
......
372 372
    @Test
373 373
    public void testCdDvdGetTitleCache() {
374 374
        String result = defaultStrategy.getTitleCache(cdDvd);
375
        assertEquals(cdDvdTitle + ". 1999"+SEP+"2001", result);
375
        //TODO position of year needs to be discussed
376
        assertEquals("1999"+SEP+"2001: " + cdDvdTitle + ".", result);
376 377
    }
377 378

  
378 379
// *************************** GENERIC *****************************************/
......
392 393
        Reference inRef = (Reference)book1;
393 394
        generic1.setInReference(inRef);
394 395
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
395
        Assert.assertEquals("Unexpected title cache.", "Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title", generic1.getTitleCache());
396
        Assert.assertEquals("Unexpected title cache.", "Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
396 397
    }
397 398

  
398 399
    @Test
......
408 409
        generic1.setInReference(inRef);
409 410
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
410 411
        generic1.setAbbrevTitleCache(null, false);  //reset cache in case aspectJ is not enabled
411
        Assert.assertEquals("Unexpected abbrev title cache.", "Pt. Tit. "+UTF8.EN_DASH+" In: AT., My bk. tit. 1987", generic1.getAbbrevTitleCache());
412
        Assert.assertEquals("Title cache must still be the same", "Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title. 1987", generic1.getTitleCache());
412
        //TODO needs discussion
413
        Assert.assertEquals("Unexpected abbrev title cache.", "1987: Pt. Tit. "+UTF8.EN_DASH+" In: AT., My bk. tit.", generic1.getAbbrevTitleCache());
414
        Assert.assertEquals("Title cache must still be the same", "1987: Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
413 415

  
414 416
        //protected
415 417
        generic1.setAbbrevTitleCache("My prot. abb. tit. in a bk.", true);
416 418
        Assert.assertEquals("Unexpected abbrev title cache.", "My prot. abb. tit. in a bk.", generic1.getAbbrevTitleCache());
417
        Assert.assertEquals("Unexpected title cache.", "Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title. 1987", generic1.getTitleCache());
419
        Assert.assertEquals("Unexpected title cache.", "1987: Part Title. "+UTF8.EN_DASH+" In: Authorteam, My book title.", generic1.getTitleCache());
418 420
    }
419 421

  
420 422
    @Test
......
422 424
        generic1.setTitle("My generic title");
423 425
        generic1.setAuthorship(genericTeam1);
424 426
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
425
        Assert.assertEquals("Unexpected title cache.", "Authorteam, My generic title", generic1.getTitleCache());
427
        Assert.assertEquals("Unexpected title cache.", "Authorteam: My generic title.", generic1.getTitleCache());
426 428
    }
427 429

  
428 430
    @Test
429 431
    public void testGenericAuthorOnly(){
430 432
        generic1.setAuthorship(genericTeam1);
431 433
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
432
        Assert.assertEquals("Unexpected title cache.", "Authorteam", generic1.getTitleCache());
434
        Assert.assertEquals("Unexpected title cache.", "Authorteam.", generic1.getTitleCache());
433 435
    }
434 436

  
435 437
    @Test
......
437 439
        generic1.setAuthorship(genericTeam1);
438 440
        generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1792"));
439 441
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
440
        Assert.assertEquals("Unexpected title cache.", "Authorteam, 1792", generic1.getTitleCache());
442
        Assert.assertEquals("Unexpected title cache.", "Authorteam 1792.", generic1.getTitleCache());
441 443
    }
442 444

  
443 445
    //#4338
......
448 450
        generic1.setDatePublished(TimePeriodParser.parseStringVerbatim("1883-1884"));
449 451
        generic1.setTitleCache(null, false);  //reset cache in case aspectJ is not enabled
450 452
        generic1.setVolume("7");
451
        Assert.assertEquals("Authorteam, My generic 7. 1883"+SEP+"1884", generic1.getTitleCache());
452
        Assert.assertEquals("AT., My generic 7. 1883"+SEP+"1884", generic1.getAbbrevTitleCache());
453
        Assert.assertEquals("Authorteam 1883"+SEP+"1884: My generic 7.", generic1.getTitleCache());
454
        Assert.assertEquals("AT. 1883"+SEP+"1884: My generic 7.", generic1.getAbbrevTitleCache());
453 455

  
454 456
        //inRef
455 457
        Reference generic2 = ReferenceFactory.newGeneric();
......
471 473

  
472 474
        //only inref has volume
473 475
        generic1.setVolume(null);
474
        Assert.assertEquals("Authorteam: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9. 1883"+SEP+"1884", generic1.getTitleCache());
475
        Assert.assertEquals("AT.: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9. 1883"+SEP+"1884", generic1.getAbbrevTitleCache());
476
        Assert.assertEquals("Authorteam 1883"+SEP+"1884: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9.", generic1.getTitleCache());
477
        Assert.assertEquals("AT. 1883"+SEP+"1884: My generic. "+UTF8.EN_DASH+" In: InRefAuthor, My InRef 9.", generic1.getAbbrevTitleCache());
476 478
   }
477 479

  
478 480
// ********************************** WEB PAGE ********************************************/
......
489 491
        webPage1.setAuthorship(webPageTeam1);
490 492
        webPage1.setAccessed(DateTime.parse("2001-01-05"));
491 493
        Assert.assertEquals("Unexpected title cache.",
492
                "Authorteam, D., Flora of Israel Online "+UTF8.EN_DASH+" http://flora.huji.ac.il [accessed 2001-01-05]",
494
                "Authorteam, D.: Flora of Israel Online "+UTF8.EN_DASH+" http://flora.huji.ac.il [accessed 2001-01-05]",
493 495
                webPage1.getTitleCache());
494 496
    }
495 497

  

Also available in: Unified diff