Project

General

Profile

Download (2.53 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.apache.log4j.Logger;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.junit.Assert;
16
import org.junit.BeforeClass;
17
import org.junit.Test;
18

    
19
import eu.etaxonomy.cdm.model.taxon.Taxon;
20

    
21
/**
22
 * @author n.hoffmann
23
 * @created 08.04.2009
24
 * @version 1.0
25
 */
26
public class DeleteTaxonOperationTest extends AbstractTaxeditorOperationTest{
27
	private static final Logger logger = Logger
28
			.getLogger(DeleteTaxonOperationTest.class);
29
	
30
	private static Taxon child;
31
	
32
	/**
33
	 * @throws java.lang.Exception
34
	 */
35
	@BeforeClass
36
	public static void setUpBeforeClass() throws Exception {
37
		// TODO get taxon from integration test data
38
		taxon = Taxon.NewInstance(null, null);
39
		
40
		child = Taxon.NewInstance(null, null);
41
		
42
		taxon.addTaxonomicChild(child, null, null);
43
		
44
		operation = new DeleteTaxonOperation("Delete Taxon", undoContext, taxon);
45
	}
46

    
47
	/**
48
	 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
49
	 * @throws ExecutionException 
50
	 */
51
	@Test
52
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
53

    
54
		operation.execute(monitor, info);
55
	
56
		Assert.assertTrue(taxon.getTaxonomicChildren().size() == 0);
57
		Assert.assertTrue(taxon.getTaxonomicChildrenCount() == 0);
58
	}
59

    
60
	/**
61
	 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
62
	 * @throws ExecutionException 
63
	 */
64
	@Test
65
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
66

    
67
		operation.execute(monitor, info);
68
	
69
		Assert.assertTrue(taxon.getTaxonomicChildren().size() > 0);
70
		Assert.assertTrue(taxon.getTaxonomicChildrenCount() > 0);
71
	}
72
	
73
	/**
74
	 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
75
	 * @throws ExecutionException 
76
	 */
77
	@Test
78
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
79

    
80
		operation.execute(monitor, info);
81
	
82
		Assert.assertTrue(taxon.getTaxonomicChildren().size() == 0);
83
		Assert.assertTrue(taxon.getTaxonomicChildrenCount() == 0);
84
	}
85
}
(20-20/22)