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 junit.framework.Assert;
|
13
|
|
14
|
import org.apache.log4j.Logger;
|
15
|
import org.eclipse.core.commands.ExecutionException;
|
16
|
import org.junit.BeforeClass;
|
17
|
import org.junit.Test;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
20
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
21
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
22
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
24
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
25
|
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation;
|
26
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
27
|
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
|
28
|
|
29
|
/**
|
30
|
* @author n.hoffmann
|
31
|
* @created 02.04.2009
|
32
|
* @version 1.0
|
33
|
*/
|
34
|
public class ChangeHomotypicGroupOperationTest extends AbstractTaxeditorOperationTestBase {
|
35
|
private static final Logger logger = Logger
|
36
|
.getLogger(ChangeHomotypicGroupOperationTest.class);
|
37
|
|
38
|
|
39
|
private static AbstractPostOperation operation;
|
40
|
|
41
|
|
42
|
private static Taxon taxon;
|
43
|
|
44
|
|
45
|
private static Synonym synonym;
|
46
|
|
47
|
|
48
|
private static HomotypicalGroup newHomotypicalGroup;
|
49
|
|
50
|
|
51
|
private static HomotypicalGroup oldHomotypicalGroup;
|
52
|
|
53
|
/**
|
54
|
* @throws java.lang.Exception
|
55
|
*/
|
56
|
@BeforeClass
|
57
|
public static void setUpBeforeClass() throws Exception {
|
58
|
|
59
|
taxon = Taxon.NewInstance(null, null);
|
60
|
synonym = Synonym.NewInstance(TaxonNameBase.NewNonViralInstance(null), null);
|
61
|
|
62
|
oldHomotypicalGroup = HomotypicalGroup.NewInstance();
|
63
|
oldHomotypicalGroup.addTypifiedName(synonym.getName());
|
64
|
|
65
|
newHomotypicalGroup = HomotypicalGroup.NewInstance();
|
66
|
|
67
|
operation = new ChangeHomotypicGroupOperation("Change Homotypical Group", null, taxon, synonym, newHomotypicalGroup, postOperation);
|
68
|
}
|
69
|
|
70
|
|
71
|
/**
|
72
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
73
|
* @throws ExecutionException
|
74
|
*/
|
75
|
@Test
|
76
|
public void testExecute() throws ExecutionException {
|
77
|
operation.execute(null, null);
|
78
|
|
79
|
Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
84
|
* @throws ExecutionException
|
85
|
*/
|
86
|
@Test
|
87
|
public void testUndo() throws ExecutionException {
|
88
|
operation.undo(null, null);
|
89
|
|
90
|
Assert.assertEquals(oldHomotypicalGroup, synonym.getHomotypicGroup());
|
91
|
}
|
92
|
|
93
|
/**
|
94
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
95
|
* @throws ExecutionException
|
96
|
*/
|
97
|
@Test
|
98
|
public void testRedo() throws ExecutionException {
|
99
|
operation.redo(null, null);
|
100
|
|
101
|
Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
|
106
|
*/
|
107
|
@Test
|
108
|
public void testPostExecute() {
|
109
|
// TODO there is not post operation functionality for this class
|
110
|
// at the moment. Implement test when there is.
|
111
|
logger.warn("No post operation functionality for this class");
|
112
|
}
|
113
|
}
|