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