1
|
|
2
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
3
|
|
4
|
import junit.framework.Assert;
|
5
|
|
6
|
import org.apache.log4j.Logger;
|
7
|
import org.eclipse.core.commands.ExecutionException;
|
8
|
import org.junit.BeforeClass;
|
9
|
import org.junit.Test;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
|
12
|
import eu.etaxonomy.cdm.model.description.Feature;
|
13
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
14
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
15
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.CreateDescriptionElementOperation;
|
16
|
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
|
17
|
|
18
|
public class CreateDescriptionElementOperationTest extends AbstractTaxeditorOperationTestBase {
|
19
|
private static final Logger logger = Logger
|
20
|
.getLogger(CreateDescriptionElementOperationTest.class);
|
21
|
|
22
|
|
23
|
private static TaxonDescription description;
|
24
|
|
25
|
private static Feature feature;
|
26
|
|
27
|
private final DescriptionElementBase[] arrayType = new DescriptionElementBase[0];
|
28
|
|
29
|
@BeforeClass
|
30
|
public static void setUpBeforeClass() throws Exception {
|
31
|
taxon = Taxon.NewInstance(null, null);
|
32
|
description = TaxonDescription.NewInstance();
|
33
|
feature = Feature.NewInstance();
|
34
|
|
35
|
operation = new CreateDescriptionElementOperation("Add Element", null, description, feature, postOperation);
|
36
|
}
|
37
|
|
38
|
|
39
|
@Test
|
40
|
public void testExecute() throws ExecutionException {
|
41
|
operation.execute(monitor, info);
|
42
|
|
43
|
Assert.assertTrue(description.getElements().size() > 0);
|
44
|
Assert.assertEquals(feature, description.getElements().toArray(arrayType)[0].getFeature());
|
45
|
}
|
46
|
|
47
|
@Test
|
48
|
public void testUndo() throws ExecutionException {
|
49
|
operation.undo(monitor, info);
|
50
|
|
51
|
Assert.assertTrue(description.getElements().size() == 0);
|
52
|
}
|
53
|
|
54
|
@Test
|
55
|
public void testRedo() throws ExecutionException {
|
56
|
operation.redo(monitor, info);
|
57
|
|
58
|
Assert.assertTrue(description.getElements().size() > 0);
|
59
|
Assert.assertEquals(feature, description.getElements().toArray(arrayType)[0].getFeature());
|
60
|
}
|
61
|
}
|