Project

General

Profile

Download (3.13 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.description.DescriptionElementBase;
19
import eu.etaxonomy.cdm.model.description.TaxonDescription;
20
import eu.etaxonomy.cdm.model.description.TextData;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;
23
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
24

    
25
/**
26
 * @author n.hoffmann
27
 * @created 08.04.2009
28
 * @version 1.0
29
 */
30
public class DeleteDescriptionElementOperationTest extends AbstractTaxeditorOperationTestBase {
31

    
32
	private static DescriptionElementBase descriptionElement;
33

    
34
	private static TaxonDescription description;
35
	
36
	/**
37
	 * @throws java.lang.Exception
38
	 */
39
	@BeforeClass
40
	public static void setUpBeforeClass() throws Exception {
41
		taxon = Taxon.NewInstance(null, null);
42
		descriptionElement = TextData.NewInstance();
43
		
44
		description = TaxonDescription.NewInstance();
45
		
46
		description.addElement(descriptionElement);
47
		
48
		taxon.addDescription(description);
49
		
50
		
51
		operation = new DeleteDescriptionElementOperation("", undoContext, descriptionElement, postOperation);
52
	}
53

    
54
	/**
55
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
56
	 * @throws ExecutionException 
57
	 */
58
	@Test
59
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
60
		operation.execute(monitor, info);
61
		
62
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
63
	}
64

    
65
	/**
66
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
67
	 * @throws ExecutionException 
68
	 */
69
	@Test
70
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
71
		operation.undo(monitor, info);
72
		
73
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() > 0);
74
		Assert.assertEquals(descriptionElement, taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().toArray(new DescriptionElementBase[0])[0]);
75
	}
76

    
77
	/**
78
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
79
	 * @throws ExecutionException 
80
	 */
81
	@Test
82
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
83
		operation.redo(monitor, info);
84
		
85
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
86
	}
87
}
(13-13/17)