Revision 9dc896c9
Added by Andreas Müller almost 7 years ago
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/name/HomotypicalGroupTest.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
33 | 33 |
|
34 | 34 |
private static HomotypicalGroup group1; |
35 | 35 |
private static HomotypicalGroup group2; |
36 |
private static TaxonNameBase name1;
|
|
37 |
private static TaxonNameBase name2;
|
|
38 |
private static TaxonNameBase name3;
|
|
39 |
private static TaxonNameBase name4;
|
|
40 |
|
|
41 |
|
|
36 |
private static TaxonName name1; |
|
37 |
private static TaxonName name2; |
|
38 |
private static TaxonName name3; |
|
39 |
private static TaxonName name4; |
|
40 |
|
|
41 |
|
|
42 | 42 |
/** |
43 | 43 |
* @throws java.lang.Exception |
44 | 44 |
*/ |
... | ... | |
71 | 71 |
@After |
72 | 72 |
public void tearDown() throws Exception { |
73 | 73 |
} |
74 |
|
|
74 |
|
|
75 | 75 |
//*********************** TESTS ***********************************************/ |
76 |
|
|
76 |
|
|
77 | 77 |
@Test |
78 | 78 |
public void testGetBasionyms() { |
79 | 79 |
name1.addBasionym(name2); |
80 |
Set<TaxonNameBase> basionyms = name1.getHomotypicalGroup().getBasionyms();
|
|
80 |
Set<TaxonName> basionyms = name1.getHomotypicalGroup().getBasionyms(); |
|
81 | 81 |
Assert.assertNotNull("Basionym set should not be null", basionyms); |
82 | 82 |
Assert.assertEquals("Number of basionyms should be 1", 1, basionyms.size()); |
83 | 83 |
name3.addBasionym(name2); |
... | ... | |
88 | 88 |
basionyms = name2.getHomotypicalGroup().getBasionyms(); |
89 | 89 |
Assert.assertEquals("Number of basionyms should be 2", 2, basionyms.size()); |
90 | 90 |
// Assert.assertEquals("", name2, basionyms.iterator().next()); |
91 |
|
|
91 |
|
|
92 | 92 |
} |
93 |
|
|
93 |
|
|
94 | 94 |
@Test |
95 | 95 |
public void testGetReplacedSynonym() { |
96 | 96 |
name3.addReplacedSynonym(name4, null, null, null); |
97 |
Set<TaxonNameBase> replacedSyn = name3.getHomotypicalGroup().getReplacedSynonym();
|
|
97 |
Set<TaxonName> replacedSyn = name3.getHomotypicalGroup().getReplacedSynonym(); |
|
98 | 98 |
Assert.assertNotNull("Replaced synonym set should not be null", replacedSyn); |
99 | 99 |
Assert.assertEquals("Number of replaced synonym should be 1", 1, replacedSyn.size()); |
100 | 100 |
} |
101 |
|
|
101 |
|
|
102 | 102 |
@Test |
103 | 103 |
public void testGetBasionymAndReplacedSynonymRelations(){ |
104 | 104 |
name1.addBasionym(name2); |
... | ... | |
106 | 106 |
name4.addReplacedSynonym(name2, null, null, null); |
107 | 107 |
Set<NameRelationship> rels = name2.getHomotypicalGroup().getBasionymAndReplacedSynonymRelations(); |
108 | 108 |
Assert.assertEquals("Number of relations should be 3", 3, rels.size()); |
109 |
|
|
109 |
|
|
110 | 110 |
} |
111 | 111 |
|
112 | 112 |
@Test |
113 | 113 |
public void testGetUnrelatedNames(){ |
114 | 114 |
name1.addBasionym(name2); |
115 | 115 |
name4.addReplacedSynonym(name2, null, null, null); |
116 |
Set<TaxonNameBase> unrelatedNames = name2.getHomotypicalGroup().getUnrelatedNames();
|
|
116 |
Set<TaxonName> unrelatedNames = name2.getHomotypicalGroup().getUnrelatedNames(); |
|
117 | 117 |
Assert.assertEquals("Number of unrelatedNames should be 0", 0, unrelatedNames.size()); |
118 | 118 |
name1.getHomotypicalGroup().merge(name3.getHomotypicalGroup()); |
119 | 119 |
unrelatedNames = name2.getHomotypicalGroup().getUnrelatedNames(); |
120 | 120 |
Assert.assertEquals("Number of unrelatedNames should be 1", 1, unrelatedNames.size()); |
121 | 121 |
} |
122 |
|
|
122 |
|
|
123 | 123 |
@Test |
124 | 124 |
public void testSetGroupBasionym(){ |
125 |
|
|
125 |
|
|
126 | 126 |
name1.mergeHomotypicGroups(name2); |
127 | 127 |
name1.mergeHomotypicGroups(name3); |
128 | 128 |
name2.mergeHomotypicGroups(name4); |
129 |
|
|
129 |
|
|
130 | 130 |
name3.getHomotypicalGroup().setGroupBasionym(name1); |
131 |
|
|
131 |
|
|
132 | 132 |
Assert.assertEquals(1, name2.getBasionyms().size()); |
133 | 133 |
Assert.assertEquals(1, name3.getBasionyms().size()); |
134 | 134 |
Assert.assertEquals(1, name4.getBasionyms().size()); |
... | ... | |
137 | 137 |
|
138 | 138 |
@Test |
139 | 139 |
public void testRemoveGroupBasionym(){ |
140 |
|
|
140 |
|
|
141 | 141 |
name1.mergeHomotypicGroups(name2); |
142 | 142 |
name1.mergeHomotypicGroups(name3); |
143 | 143 |
name2.mergeHomotypicGroups(name4); |
144 |
|
|
144 |
|
|
145 | 145 |
HomotypicalGroup hg = name3.getHomotypicalGroup(); |
146 | 146 |
hg.setGroupBasionym(name1); |
147 |
|
|
147 |
|
|
148 | 148 |
Assert.assertEquals(1, name2.getBasionyms().size()); |
149 | 149 |
Assert.assertEquals(1, name3.getBasionyms().size()); |
150 | 150 |
Assert.assertEquals(1, name4.getBasionyms().size()); |
... | ... | |
164 | 164 |
@Test |
165 | 165 |
public void testClone(){ |
166 | 166 |
group1 = HomotypicalGroup.NewInstance(); |
167 |
|
|
167 |
|
|
168 | 168 |
group1.addTypifiedName(name1); |
169 | 169 |
group1.addTypifiedName(name2); |
170 | 170 |
group1.setGroupBasionym(name1); |
171 | 171 |
HomotypicalGroup clone =(HomotypicalGroup)group1.clone(); |
172 |
|
|
172 |
|
|
173 | 173 |
Assert.assertEquals(clone.getTypifiedNames().size(), group1.getTypifiedNames().size()); |
174 |
TaxonNameBase cloneBasionym = clone.getBasionyms().iterator().next();
|
|
175 |
TaxonNameBase group1Basionym = group1.getBasionyms().iterator().next();
|
|
174 |
TaxonName cloneBasionym = clone.getBasionyms().iterator().next(); |
|
175 |
TaxonName group1Basionym = group1.getBasionyms().iterator().next(); |
|
176 | 176 |
Assert.assertNotSame(cloneBasionym, group1Basionym); |
177 | 177 |
} |
178 | 178 |
*/ |
179 |
|
|
180 |
|
|
181 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 | 182 |
} |
Also available in: Unified diff
fix #6368 rename table and class TaxonNameBase