1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.navigation.navigator.operation;
|
11
|
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import org.eclipse.core.commands.ExecutionException;
|
17
|
import org.junit.Assert;
|
18
|
import org.junit.BeforeClass;
|
19
|
import org.junit.Test;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
25
|
import eu.etaxonomy.taxeditor.navigation.navigator.e4.TreeNodeDropAdapterE4.MovingType;
|
26
|
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
|
27
|
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
|
28
|
|
29
|
/**
|
30
|
* @author n.hoffmann
|
31
|
* @created 08.04.2009
|
32
|
*/
|
33
|
public class MoveTaxonOperationTest extends AbstractTaxeditorOperationTestBase {
|
34
|
|
35
|
private static Taxon oldParentTaxon;
|
36
|
private static Taxon newParentTaxon;
|
37
|
private static Classification tree;
|
38
|
private static TaxonNode oldParentTaxonNode;
|
39
|
private static TaxonNode newParentTaxonNode;
|
40
|
private static TaxonNode taxonNode;
|
41
|
|
42
|
static RemotingCdmUpdateOperation navigatorOperation;
|
43
|
|
44
|
/**
|
45
|
* @throws java.lang.Exception
|
46
|
*/
|
47
|
@BeforeClass
|
48
|
public static void setUpBeforeClass() throws Exception {
|
49
|
|
50
|
|
51
|
taxon = Taxon.NewInstance(null, null);
|
52
|
|
53
|
oldParentTaxon = Taxon.NewInstance(null, null);
|
54
|
newParentTaxon = Taxon.NewInstance(null, null);
|
55
|
|
56
|
tree = Classification.NewInstance(null);
|
57
|
oldParentTaxonNode = tree.addChildTaxon(oldParentTaxon, null, null);
|
58
|
newParentTaxonNode = tree.addChildTaxon(newParentTaxon, null, null);
|
59
|
|
60
|
taxonNode = oldParentTaxonNode.addChildTaxon(taxon, null, null);
|
61
|
|
62
|
Set<UUID> taxonNodeUuidSet = new HashSet<UUID>();
|
63
|
//TODO ??
|
64
|
IConversationEnabled conversationEnabled = null;
|
65
|
taxonNodeUuidSet.add(taxonNode.getUuid());
|
66
|
navigatorOperation = new RemotingMoveTaxonOperation(null, true, taxonNodeUuidSet, newParentTaxonNode.getUuid(), MovingType.CHILD);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
71
|
* @throws ExecutionException
|
72
|
*/
|
73
|
@Test
|
74
|
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
|
75
|
navigatorOperation.execute(monitor, info);
|
76
|
|
77
|
Assert.assertEquals(newParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
|
78
|
Assert.assertEquals(taxon, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
|
79
|
Assert.assertEquals(0, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
|
80
|
}
|
81
|
|
82
|
|
83
|
/**
|
84
|
* Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
85
|
* @throws ExecutionException
|
86
|
*/
|
87
|
@Test
|
88
|
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
|
89
|
navigatorOperation.undo(monitor, info);
|
90
|
|
91
|
Assert.assertEquals(oldParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
|
92
|
Assert.assertEquals(0, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
|
93
|
Assert.assertEquals(taxon, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
98
|
* @throws ExecutionException
|
99
|
*/
|
100
|
@Test
|
101
|
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
|
102
|
navigatorOperation.redo(monitor, info);
|
103
|
|
104
|
Assert.assertEquals(newParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
|
105
|
Assert.assertEquals(taxon, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
|
106
|
Assert.assertEquals(0, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
|
107
|
|
108
|
}
|
109
|
}
|