Project

General

Profile

Download (3.98 KB) Statistics
| Branch: | Tag: | Revision:
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.store.operations.AbstractTaxeditorOperationTestBase;
27

    
28
/**
29
 * @author n.hoffmann
30
 * @created 08.04.2009
31
 */
32
public class MoveTaxonOperationTest extends AbstractTaxeditorOperationTestBase {
33

    
34
	private static Taxon oldParentTaxon;
35
	private static Taxon newParentTaxon;
36
	private static Classification tree;
37
	private static TaxonNode oldParentTaxonNode;
38
	private static TaxonNode newParentTaxonNode;
39
	private static TaxonNode taxonNode;
40

    
41
	/**
42
	 * @throws java.lang.Exception
43
	 */
44
	@BeforeClass
45
	public static void setUpBeforeClass() throws Exception {
46

    
47

    
48
		taxon = Taxon.NewInstance(null, null);
49

    
50
		oldParentTaxon = Taxon.NewInstance(null, null);
51
		newParentTaxon = Taxon.NewInstance(null, null);
52

    
53
		tree = Classification.NewInstance(null);
54
		oldParentTaxonNode = tree.addChildTaxon(oldParentTaxon, null, null);
55
		newParentTaxonNode = tree.addChildTaxon(newParentTaxon, null, null);
56

    
57
		taxonNode = oldParentTaxonNode.addChildTaxon(taxon, null, null);
58

    
59
		Set<UUID> taxonNodeUuidSet = new HashSet<UUID>();
60
		//TODO ??
61
		IConversationEnabled conversationEnabled = null;
62
		taxonNodeUuidSet.add(taxonNode.getUuid());
63
		operation = new RemotingMoveTaxonOperation(null, true, taxonNodeUuidSet, newParentTaxonNode.getUuid(),  MovingType.CHILD);
64
	}
65

    
66
	/**
67
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
68
	 * @throws ExecutionException
69
	 */
70
	@Test
71
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
72
		operation.execute(monitor, info);
73

    
74
		Assert.assertEquals(newParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
75
		Assert.assertEquals(taxon, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
76
		Assert.assertEquals(0, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
77
	}
78

    
79

    
80
	/**
81
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
82
	 * @throws ExecutionException
83
	 */
84
	@Test
85
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
86
		operation.undo(monitor, info);
87

    
88
		Assert.assertEquals(oldParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
89
		Assert.assertEquals(0, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
90
		Assert.assertEquals(taxon, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
91
	}
92

    
93
	/**
94
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
95
	 * @throws ExecutionException
96
	 */
97
	@Test
98
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
99
		operation.redo(monitor, info);
100

    
101
		Assert.assertEquals(newParentTaxon ,taxon.getTaxonNodes().iterator().next().getParent().getTaxon());
102
		Assert.assertEquals(taxon, newParentTaxon.getTaxonNodes().iterator().next().getChildNodes().iterator().next());
103
		Assert.assertEquals(0, oldParentTaxon.getTaxonNodes().iterator().next().getChildNodes().size());
104

    
105
	}
106
}
    (1-1/1)