Revision b13da0b9
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/cdm/model/TaxonNavigatorTest.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.cdm.model; |
11 | 11 |
|
12 | 12 |
import java.util.HashSet; |
13 |
import java.util.List; |
|
13 | 14 |
import java.util.Set; |
14 | 15 |
import java.util.UUID; |
15 | 16 |
|
... | ... | |
22 | 23 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
23 | 24 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
24 | 25 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
26 |
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator; |
|
27 |
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator; |
|
28 |
import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator.ChildHandling; |
|
25 | 29 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
26 | 30 |
import eu.etaxonomy.cdm.model.common.Language; |
27 | 31 |
import eu.etaxonomy.cdm.model.description.TaxonDescription; |
28 | 32 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
33 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
34 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
|
29 | 35 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
30 | 36 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
31 | 37 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingChangeAcceptedTaxonToSynonymOperation; |
38 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingDeleteTaxonNodeOperation; |
|
32 | 39 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveFactualDataOperation; |
33 | 40 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingMoveTaxonOperation; |
34 | 41 |
import eu.etaxonomy.taxeditor.operations.BaseOperationTest; |
... | ... | |
130 | 137 |
Assert.assertTrue(targetTaxon.getDescriptions().containsAll(sourceDescriptions)); |
131 | 138 |
} |
132 | 139 |
|
140 |
@Test |
|
141 |
public void testDeleteTaxonNodeWithDeleteChildren() throws ExecutionException { |
|
142 |
UUID taxonNodeUuid = UUID.fromString("2f05d429-632d-4230-b9cb-70299360b470"); |
|
143 |
TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid); |
|
144 |
List<TaxonNode> childNodes = taxonNode.getChildNodes(); |
|
145 |
Assert.assertTrue(taxonNode.getCountChildren() > 0); |
|
146 |
|
|
147 |
Set<ITaxonTreeNode> nodes = new HashSet<ITaxonTreeNode>(); |
|
148 |
nodes.add(taxonNode); |
|
149 |
|
|
150 |
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator(); |
|
151 |
configNodes.setChildHandling(ChildHandling.DELETE); |
|
152 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
153 |
config.setTaxonNodeConfig(configNodes); |
|
154 |
|
|
155 |
sessionOwner.addExpectedUpdatedObject(taxonNode.getParent()); |
|
156 |
|
|
157 |
operation = new RemotingDeleteTaxonNodeOperation(sessionOwner, |
|
158 |
false, |
|
159 |
nodes, |
|
160 |
config); |
|
161 |
operation.execute(monitor, info); |
|
162 |
TaxonNode reloadedNode = taxonNodeService.load(taxonNode.getUuid()); |
|
163 |
Assert.assertNull(reloadedNode); |
|
164 |
for(TaxonNode childNode : childNodes) { |
|
165 |
TaxonNode reloadedChildNode = taxonNodeService.load(childNode.getUuid()); |
|
166 |
Assert.assertNull(reloadedChildNode); |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
170 |
@Test |
|
171 |
public void testDeleteTaxonNodes() throws ExecutionException { |
|
172 |
UUID taxonNode1Uuid = UUID.fromString("99f03b56-67cd-4e01-9ceb-2362d48f9d07"); |
|
173 |
UUID taxonNode2Uuid = UUID.fromString("91698cec-615f-4472-9002-feda1a6acded"); |
|
174 |
UUID taxonNode3Uuid = UUID.fromString("4fe03763-b966-4361-8334-352f6f777588"); |
|
175 |
|
|
176 |
TaxonNode taxonNode1 = taxonNodeService.load(taxonNode1Uuid); |
|
177 |
TaxonNode taxonNode2 = taxonNodeService.load(taxonNode2Uuid); |
|
178 |
TaxonNode taxonNode3 = taxonNodeService.load(taxonNode3Uuid); |
|
179 |
|
|
180 |
Set<ITaxonTreeNode> nodes = new HashSet<ITaxonTreeNode>(); |
|
181 |
nodes.add(taxonNode1); |
|
182 |
nodes.add(taxonNode2); |
|
183 |
nodes.add(taxonNode3); |
|
184 |
|
|
185 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
186 |
|
|
187 |
|
|
188 |
sessionOwner.addExpectedUpdatedObject(taxonNode1.getParent()); |
|
189 |
sessionOwner.addExpectedUpdatedObject(taxonNode2.getParent()); |
|
190 |
sessionOwner.addExpectedUpdatedObject(taxonNode3.getParent()); |
|
191 |
operation = new RemotingDeleteTaxonNodeOperation(sessionOwner, |
|
192 |
false, |
|
193 |
nodes, |
|
194 |
config); |
|
195 |
operation.execute(monitor, info); |
|
196 |
TaxonNode reloadedNode1 = taxonNodeService.load(taxonNode1.getUuid()); |
|
197 |
TaxonNode reloadedNode2 = taxonNodeService.load(taxonNode2.getUuid()); |
|
198 |
TaxonNode reloadedNode3 = taxonNodeService.load(taxonNode3.getUuid()); |
|
199 |
Assert.assertNull(reloadedNode1); |
|
200 |
Assert.assertNull(reloadedNode2); |
|
201 |
Assert.assertNull(reloadedNode3); |
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
@Test |
|
206 |
public void testDeleteTaxonNodeWithMovingChildrenToParentNode() throws ExecutionException { |
|
207 |
UUID taxonNodeUuid = UUID.fromString("2f05d429-632d-4230-b9cb-70299360b470"); |
|
208 |
TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid); |
|
209 |
TaxonNode parentTaxonNode = taxonNode.getParent(); |
|
210 |
List<TaxonNode> childNodes = taxonNode.getChildNodes(); |
|
211 |
Assert.assertTrue(taxonNode.getCountChildren() > 0); |
|
212 |
|
|
213 |
Set<ITaxonTreeNode> nodes = new HashSet<ITaxonTreeNode>(); |
|
214 |
nodes.add(taxonNode); |
|
215 |
|
|
216 |
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator(); |
|
217 |
configNodes.setChildHandling(ChildHandling.MOVE_TO_PARENT); |
|
218 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
219 |
config.setTaxonNodeConfig(configNodes); |
|
220 |
|
|
221 |
sessionOwner.addExpectedUpdatedObject(taxonNode.getParent()); |
|
222 |
operation = new RemotingDeleteTaxonNodeOperation(sessionOwner, |
|
223 |
false, |
|
224 |
nodes, |
|
225 |
config); |
|
226 |
operation.execute(monitor, info); |
|
227 |
TaxonNode reloadedNode = taxonNodeService.load(taxonNode.getUuid()); |
|
228 |
Assert.assertNull(reloadedNode); |
|
229 |
List<TaxonNode> parentChildNodes = parentTaxonNode.getChildNodes(); |
|
230 |
Assert.assertTrue(parentChildNodes.containsAll(childNodes)); |
|
231 |
} |
|
232 |
|
|
233 |
@Test |
|
234 |
@DataSet("TaxonNavigatorTest.testDeleteClassificationWithDeleteChildren.xml") |
|
235 |
public void testDeleteClassificationWithDeleteChildren() throws ExecutionException { |
|
236 |
UUID classificationUuid = UUID.fromString("0c2b5d25-7b15-4401-8b51-dd4be0ee5cab"); |
|
237 |
Classification classification = classificationService.load(classificationUuid); |
|
238 |
TaxonNode rootNode = classification.getRootNode(); |
|
239 |
Set<ITaxonTreeNode> nodes = new HashSet<ITaxonTreeNode>(); |
|
240 |
nodes.add(classification); |
|
241 |
|
|
242 |
TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator(); |
|
243 |
configNodes.setChildHandling(ChildHandling.DELETE); |
|
244 |
TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); |
|
245 |
config.setTaxonNodeConfig(configNodes); |
|
246 |
|
|
247 |
operation = new RemotingDeleteTaxonNodeOperation(sessionOwner, |
|
248 |
false, |
|
249 |
nodes, |
|
250 |
config); |
|
251 |
operation.execute(monitor, info); |
|
252 |
|
|
253 |
Classification reloadedClassification = classificationService.load(classification.getUuid()); |
|
254 |
Assert.assertNull(reloadedClassification); |
|
255 |
TaxonNode reloadedRootNode = taxonNodeService.load(rootNode.getUuid()); |
|
256 |
Assert.assertNull(reloadedRootNode); |
|
257 |
|
|
258 |
} |
|
259 |
|
|
133 | 260 |
|
134 | 261 |
} |
Also available in: Unified diff
#5007 : Add remoting handler / operations for the taxon navigator