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