Revision 90046bc4
Added by Andreas Müller almost 8 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/strategy/cache/reference/ArticleDefaultCacheStrategyTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2009 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.strategy.cache.reference; |
11 | 11 |
|
12 | 12 |
|
13 |
import org.junit.Assert; |
|
14 |
|
|
15 | 13 |
import org.apache.log4j.Logger; |
14 |
import org.junit.Assert; |
|
16 | 15 |
import org.junit.Before; |
17 | 16 |
import org.junit.BeforeClass; |
18 | 17 |
import org.junit.Ignore; |
... | ... | |
33 | 32 |
public class ArticleDefaultCacheStrategyTest { |
34 | 33 |
@SuppressWarnings("unused") |
35 | 34 |
private static final Logger logger = Logger.getLogger(ArticleDefaultCacheStrategyTest.class); |
36 |
|
|
35 |
|
|
37 | 36 |
private static IArticle article1; |
38 | 37 |
private static IJournal journal1; |
39 | 38 |
private static Team team1; |
40 | 39 |
private static Team team2; |
41 | 40 |
private static ArticleDefaultCacheStrategy defaultStrategy; |
42 | 41 |
private static final String detail1 = "55"; |
43 |
|
|
42 |
|
|
44 | 43 |
/** |
45 | 44 |
* @throws java.lang.Exception |
46 | 45 |
*/ |
... | ... | |
64 | 63 |
team2.setTitleCache("Team2", true); |
65 | 64 |
team2.setNomenclaturalTitle("TT.", true); |
66 | 65 |
} |
67 |
|
|
66 |
|
|
68 | 67 |
//**************************** TESTS *********************************** |
69 | 68 |
|
70 |
|
|
69 |
|
|
71 | 70 |
@Test |
72 | 71 |
public void testGetTitleCache(){ |
73 | 72 |
journal1.setTitle("My journal"); |
... | ... | |
81 | 80 |
article1.setInJournal(null); |
82 | 81 |
//TODO should not be needed here |
83 | 82 |
article1.setTitleCache(null, false); |
84 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
|
83 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache()); |
|
85 | 84 |
} |
86 |
|
|
85 |
|
|
87 | 86 |
@Ignore |
88 | 87 |
@Test |
89 | 88 |
//This test is just to show that there is still the title cache bug which is not |
... | ... | |
98 | 97 |
Assert.assertEquals("Team1, My article in My journal. 1975", article1.getTitleCache()); |
99 | 98 |
|
100 | 99 |
article1.setInJournal(null); |
101 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
|
100 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache()); |
|
102 | 101 |
} |
103 |
|
|
102 |
|
|
104 | 103 |
@Test |
105 | 104 |
public void testGetAbbrevTitleCache(){ |
106 |
|
|
105 |
|
|
107 | 106 |
journal1.setTitle("My journal"); |
108 | 107 |
journal1.setTitle("M. Journ."); |
109 | 108 |
journal1.setAuthorship(team2); |
... | ... | |
117 | 116 |
article1.setInJournal(null); |
118 | 117 |
//TODO should not be needed here |
119 | 118 |
article1.setTitleCache(null, false); |
120 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache());
|
|
119 |
Assert.assertEquals("Team1, My article in " + ArticleDefaultCacheStrategy.UNDEFINED_JOURNAL + ". 1975", article1.getTitleCache()); |
|
121 | 120 |
} |
122 | 121 |
|
123 | 122 |
@Test |
... | ... | |
130 | 129 |
article1.setAuthorship(team1); |
131 | 130 |
article1.setDatePublished(TimePeriod.NewInstance(1975)); |
132 | 131 |
Assert.assertEquals("in M. J.: 55. 1975", article1.getNomenclaturalCitation(detail1)); |
133 |
|
|
132 |
|
|
134 | 133 |
article1.setVolume("22"); |
135 | 134 |
Assert.assertEquals("in M. J. 22: 55. 1975", article1.getNomenclaturalCitation(detail1)); |
136 | 135 |
article1.setSeriesPart("ser. 11"); |
... | ... | |
138 | 137 |
} |
139 | 138 |
|
140 | 139 |
/** |
141 |
* After ser. , sect. , abt. we want to have a comma, if there is not yet one following anyway
|
|
140 |
* After ser. , sect. , abt. we want to have a comma, if there is not yet one following anyway |
|
142 | 141 |
*/ |
143 | 142 |
@Test |
144 | 143 |
public void testGetNomenclaturalCitationSerSectAbt(){ |
... | ... | |
170 | 169 |
Assert.assertEquals("in J. Pl. Eur., Abt. 3, 22: 55. 1975", article1.getNomenclaturalCitation(detail1)); |
171 | 170 |
journal1.setAbbrevTitle("J. Pl. Eur., abt. 3, no comma"); |
172 | 171 |
Assert.assertEquals("in J. Pl. Eur., abt. 3, no comma 22: 55. 1975", article1.getNomenclaturalCitation(detail1)); |
173 |
|
|
172 |
|
|
174 | 173 |
journal1.setAbbrevTitle("J. Pl. Eur., sect. 3"); |
175 | 174 |
article1.setSeriesPart("1"); |
176 | 175 |
Assert.assertEquals("in J. Pl. Eur., sect. 3, ser. 1, 22: 55. 1975", article1.getNomenclaturalCitation(detail1)); |
... | ... | |
179 | 178 |
} |
180 | 179 |
|
181 | 180 |
|
182 |
|
|
183 |
@Test
|
|
181 |
|
|
182 |
@Test |
|
184 | 183 |
public void testGetTitleWithoutYearAndAuthor(){ |
185 | 184 |
journal1.setTitle("My journal"); |
186 | 185 |
journal1.setAuthorship(team2); |
... | ... | |
190 | 189 |
article1.setVolume("34"); |
191 | 190 |
article1.setSeriesPart("ser. 2"); |
192 | 191 |
article1.setDatePublished(TimePeriod.NewInstance(1975)); |
193 |
Assert.assertEquals("in My journal, ser. 2, 34", defaultStrategy.getTitleWithoutYearAndAuthor((Reference<?>)article1, false));
|
|
192 |
Assert.assertEquals("in My journal, ser. 2, 34", defaultStrategy.getTitleWithoutYearAndAuthor((Reference)article1, false)); |
|
194 | 193 |
} |
195 |
|
|
196 |
@Test
|
|
194 |
|
|
195 |
@Test |
|
197 | 196 |
public void testOldExistingBugs(){ |
198 | 197 |
journal1.setTitle("Univ. Calif. Publ. Bot."); |
199 | 198 |
journal1.setAuthorship(null); |
200 |
|
|
199 |
|
|
201 | 200 |
Team articleAuthor = Team.NewTitledInstance("Babc. & Stebbins", "Babc. & Stebbins"); |
202 | 201 |
article1.setTitle(""); |
203 | 202 |
article1.setInJournal(journal1); |
204 | 203 |
article1.setAuthorship(articleAuthor); |
205 | 204 |
article1.setVolume("18"); |
206 | 205 |
article1.setDatePublished(TimePeriod.NewInstance(1943)); |
207 |
Assert.assertEquals("Babc. & Stebbins in Univ. Calif. Publ. Bot. 18. 1943", defaultStrategy.getTitleCache((Reference<?>)article1));
|
|
206 |
Assert.assertEquals("Babc. & Stebbins in Univ. Calif. Publ. Bot. 18. 1943", defaultStrategy.getTitleCache((Reference)article1)); |
|
208 | 207 |
} |
209 |
|
|
208 |
|
|
210 | 209 |
} |
Also available in: Unified diff
Remove generics from Reference in cdmlib-model #5830