Project

General

Profile

Download (3.31 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.store.operations;
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

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

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

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

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

    
72

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