Project

General

Profile

Download (3.43 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.taxeditor.editor.name.operation;
12

    
13
import org.eclipse.core.commands.ExecutionException;
14
import org.junit.Assert;
15
import org.junit.BeforeClass;
16
import org.junit.Test;
17

    
18
import eu.etaxonomy.cdm.model.taxon.Classification;
19
import eu.etaxonomy.cdm.model.taxon.Taxon;
20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
22

    
23
/**
24
 * @author n.hoffmann
25
 * @created 08.04.2009
26
 * @version 1.0
27
 */
28
public class MoveTaxonOperationTest extends AbstractTaxeditorOperationTestBase {
29

    
30
	private static Taxon oldParentTaxon;
31
	private static Taxon newParentTaxon;
32
	private static Classification tree;
33
	private static TaxonNode oldParentTaxonNode;
34
	private static TaxonNode newParentTaxonNode;
35
	private static TaxonNode taxonNode;
36
	
37
	/**
38
	 * @throws java.lang.Exception
39
	 */
40
	@BeforeClass
41
	public static void setUpBeforeClass() throws Exception {
42

    
43
		
44
		taxon = Taxon.NewInstance(null, null);
45
		
46
		
47
		
48
		oldParentTaxon = Taxon.NewInstance(null, null);
49
		newParentTaxon = Taxon.NewInstance(null, null);
50
		
51
		tree = Classification.NewInstance(null);
52
		oldParentTaxonNode = tree.addChildTaxon(oldParentTaxon, null, null, null);
53
		newParentTaxonNode = tree.addChildTaxon(newParentTaxon, null, null, null);
54
		
55
		taxonNode = oldParentTaxonNode.addChildTaxon(taxon, null, null, null);
56
		
57
		operation = null;//new MoveTaxonOperation("Move Taxon To Different Parent", undoContext, taxonNode, newParentTaxonNode, postOperation);
58
	}
59

    
60
	/**
61
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
62
	 * @throws ExecutionException 
63
	 */
64
	@Test
65
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
66
		operation.execute(monitor, info);
67
		
68
		Assert.assertEquals(newParentTaxon ,taxon.getTaxonomicParent());
69
		Assert.assertEquals(taxon, newParentTaxon.getTaxonomicChildren().toArray(new Taxon[0])[0]);
70
		Assert.assertTrue(oldParentTaxon.getTaxonomicChildrenCount() == 0);
71
	}
72

    
73

    
74
	/**
75
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
76
	 * @throws ExecutionException 
77
	 */
78
	@Test
79
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
80
		operation.undo(monitor, info);
81
		
82
		Assert.assertEquals(oldParentTaxon ,taxon.getTaxonomicParent());
83
		Assert.assertTrue(newParentTaxon.getTaxonomicChildren().size() == 0);
84
		Assert.assertEquals(taxon, oldParentTaxon.getTaxonomicChildren().toArray(new Taxon[0])[0]);
85
	}
86
	
87
	/**
88
	 * Test method for {@link eu.etaxonomy.taxeditor.navigation.operation.MoveTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
89
	 * @throws ExecutionException 
90
	 */
91
	@Test
92
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
93
		operation.redo(monitor, info);
94
		
95
		Assert.assertEquals(newParentTaxon ,taxon.getTaxonomicParent());
96
		Assert.assertEquals(taxon, newParentTaxon.getTaxonomicChildren().toArray(new Taxon[0])[0]);
97
		Assert.assertTrue(oldParentTaxon.getTaxonomicChildrenCount() == 0);
98
	}
99
}
(16-16/17)