Revision 4dbcb616
Added by Andreas Müller over 3 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/location/TdwgAreaTest.java | ||
---|---|---|
18 | 18 |
|
19 | 19 |
import org.apache.log4j.Logger; |
20 | 20 |
import org.junit.Assert; |
21 |
import org.junit.Before; |
|
22 |
import org.junit.BeforeClass; |
|
23 | 21 |
import org.junit.Test; |
24 | 22 |
|
25 | 23 |
import eu.etaxonomy.cdm.model.common.Language; |
26 | 24 |
import eu.etaxonomy.cdm.model.term.DefaultTermInitializer; |
27 | 25 |
import eu.etaxonomy.cdm.model.term.Representation; |
28 | 26 |
import eu.etaxonomy.cdm.model.term.TermVocabulary; |
27 |
import eu.etaxonomy.cdm.test.unit.EntityTestBase; |
|
29 | 28 |
|
30 | 29 |
/** |
31 | 30 |
* @author a.mueller |
32 | 31 |
* @since 23.10.2008 |
33 | 32 |
*/ |
34 |
public class TdwgAreaTest { |
|
33 |
public class TdwgAreaTest extends EntityTestBase { |
|
34 |
|
|
35 | 35 |
@SuppressWarnings("unused") |
36 | 36 |
private static final Logger logger = Logger.getLogger(TdwgAreaTest.class); |
37 | 37 |
|
38 |
/** |
|
39 |
* @throws java.lang.Exception |
|
40 |
*/ |
|
41 |
@BeforeClass |
|
42 |
public static void setUpBeforeClass() throws Exception { |
|
43 |
new DefaultTermInitializer().initialize(); |
|
44 |
} |
|
45 |
|
|
46 |
/** |
|
47 |
* @throws java.lang.Exception |
|
48 |
*/ |
|
49 |
@Before |
|
50 |
public void setUp() throws Exception { |
|
51 |
} |
|
52 |
|
|
53 | 38 |
// ************** TESTS ************************************************* |
54 | 39 |
|
55 |
/** |
|
56 |
* Test method for {@link eu.etaxonomy.cdm.model.location.TdwgArea_Old#getAreaByTdwgAbbreviation(java.lang.String)}. |
|
57 |
*/ |
|
58 | 40 |
@Test |
59 | 41 |
public void testGetAreaByTdwgAbbreviation() { |
60 | 42 |
Language.ENGLISH(); // to make sure Terms are already loaded |
... | ... | |
63 | 45 |
Assert.assertNull(getAreaByTdwgAbbreviation("A1R")); |
64 | 46 |
} |
65 | 47 |
|
66 |
/** |
|
67 |
* Test method for {@link eu.etaxonomy.cdm.model.location.TdwgArea_Old#getAreaByTdwgLabel(java.lang.String)}. |
|
68 |
*/ |
|
69 | 48 |
@Test |
70 | 49 |
public void testGetAreaByTdwgLabel() { |
71 | 50 |
Assert.assertEquals("Germany", getAreaByTdwgLabel("Germany").getLabel(Language.ENGLISH())); |
72 | 51 |
Assert.assertNull(getAreaByTdwgLabel("A1R")); |
73 | 52 |
} |
74 | 53 |
|
75 |
/** |
|
76 |
* Test method for {@link eu.etaxonomy.cdm.model.location.TdwgArea_Old#isTdwgAreaLabel(java.lang.String)}. |
|
77 |
*/ |
|
78 | 54 |
@Test |
79 | 55 |
public void testIsTdwgAreaLabel() { |
80 | 56 |
Assert.assertTrue(isTdwgAreaLabel("Germany")); |
... | ... | |
132 | 108 |
initializer.initialize(); |
133 | 109 |
NamedArea saoTome = NamedArea.getTdwgTermByUuid(UUID.fromString("c64e07cc-0a58-44b3-ac91-c216d1b91c1f")); |
134 | 110 |
assertEquals("Utf8 error", "S\u00E3o Tom\u00E9", saoTome.getLabel()); |
135 |
|
|
136 | 111 |
} |
137 | 112 |
|
138 |
|
|
139 | 113 |
@Test |
140 | 114 |
public void testCompare(){ |
141 | 115 |
//test compare method for set functionality. TreeSet is used by OrderedTermVocabulary therefore |
142 | 116 |
//this needs to work correctly |
143 | 117 |
TermVocabulary voc = getAreaByTdwgAbbreviation("1").getVocabulary(); |
144 | 118 |
|
145 |
Set<NamedArea> set = new TreeSet<NamedArea>();
|
|
119 |
Set<NamedArea> set = new TreeSet<>(); |
|
146 | 120 |
NamedArea area3 = NamedArea.NewInstance(); |
147 | 121 |
area3.addRepresentation(Representation.NewInstance("Spain", "Spain", "SPA", Language.DEFAULT())); |
148 | 122 |
NamedArea area4 = NamedArea.NewInstance(); |
... | ... | |
155 | 129 |
Assert.assertEquals("There must be 2 areas in the set", 2, set.size()); |
156 | 130 |
} |
157 | 131 |
|
158 |
|
|
159 |
|
|
160 | 132 |
// @Test |
161 | 133 |
// public void getHirarchichalAreasTest(){ |
162 | 134 |
// //NamedArea area0 = getAreaByTdwgLabel("Spain"); |
... | ... | |
279 | 251 |
return aux; |
280 | 252 |
} |
281 | 253 |
|
282 |
|
|
283 | 254 |
private NamedArea getAreaByTdwgAbbreviation(String tdwgAbbrev){ |
284 | 255 |
return NamedArea.getAreaByTdwgAbbreviation(tdwgAbbrev); |
285 | 256 |
} |
... | ... | |
291 | 262 |
private boolean isTdwgAreaLabel(String tdwgLabel){ |
292 | 263 |
return NamedArea.isTdwgAreaLabel(tdwgLabel); |
293 | 264 |
} |
294 |
|
|
295 |
} |
|
265 |
} |
Also available in: Unified diff
cleanup and use TermTestBase for model tests