Project

General

Profile

Download (3.12 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.editor.name.operation;
11

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

    
17
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
18
import eu.etaxonomy.cdm.model.description.TaxonDescription;
19
import eu.etaxonomy.cdm.model.description.TextData;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation;
22
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
23

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

    
31
	private static DescriptionElementBase descriptionElement;
32

    
33
	private static TaxonDescription description;
34

    
35
	/**
36
	 * @throws java.lang.Exception
37
	 */
38
	@BeforeClass
39
	public static void setUpBeforeClass() throws Exception {
40
		taxon = Taxon.NewInstance(null, null);
41
		descriptionElement = TextData.NewInstance();
42

    
43
		description = TaxonDescription.NewInstance();
44

    
45
		description.addElement(descriptionElement);
46

    
47
		taxon.addDescription(description);
48

    
49

    
50
		operation = new DeleteDescriptionElementOperation("", undoContext, descriptionElement, postOperation, cdmEntitySessionEnabled);
51
	}
52

    
53
	/**
54
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
55
	 * @throws ExecutionException
56
	 */
57
	@Test
58
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
59
		operation.execute(monitor, info);
60

    
61
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
62
	}
63

    
64
	/**
65
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
66
	 * @throws ExecutionException
67
	 */
68
	@Test
69
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
70
		operation.undo(monitor, info);
71

    
72
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() > 0);
73
		Assert.assertEquals(descriptionElement, taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().toArray(new DescriptionElementBase[0])[0]);
74
	}
75

    
76
	/**
77
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
78
	 * @throws ExecutionException
79
	 */
80
	@Test
81
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
82
		operation.redo(monitor, info);
83

    
84
		Assert.assertTrue(taxon.getDescriptions().toArray(new TaxonDescription[0])[0].getElements().size() == 0);
85
	}
86
}
(13-13/16)