Project

General

Profile

Download (3.59 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 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.name.TaxonNameFactory;
24
import eu.etaxonomy.cdm.model.taxon.Synonym;
25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation;
27
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
28
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
29

    
30
/**
31
 * @author n.hoffmann
32
 * @created 02.04.2009
33
 * @version 1.0
34
 */
35
public class ChangeHomotypicGroupOperationTest extends AbstractTaxeditorOperationTestBase {
36
	private static final Logger logger = Logger
37
			.getLogger(ChangeHomotypicGroupOperationTest.class);
38

    
39
	
40
	private static AbstractPostOperation operation;
41

    
42

    
43
	private static Taxon taxon;
44

    
45

    
46
	private static Synonym synonym;
47

    
48

    
49
	private static HomotypicalGroup newHomotypicalGroup;
50

    
51

    
52
	private static HomotypicalGroup oldHomotypicalGroup;
53
	
54
	/**
55
	 * @throws java.lang.Exception
56
	 */
57
	@BeforeClass
58
	public static void setUpBeforeClass() throws Exception {
59
		
60
		taxon = Taxon.NewInstance(null, null);
61
		synonym = Synonym.NewInstance(TaxonNameFactory.NewNonViralInstance(null), null);
62
		
63
		oldHomotypicalGroup = HomotypicalGroup.NewInstance();
64
		oldHomotypicalGroup.addTypifiedName(synonym.getName());
65
		
66
		newHomotypicalGroup = HomotypicalGroup.NewInstance();
67
		
68
		operation = new ChangeHomotypicGroupOperation("Change Homotypical Group", null, taxon, synonym, newHomotypicalGroup, postOperation);
69
	}
70

    
71

    
72
	/**
73
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
74
	 * @throws ExecutionException 
75
	 */
76
	@Test
77
	public void testExecute() throws ExecutionException {
78
		operation.execute(null, null);
79
		
80
		Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
81
	}
82

    
83
	/**
84
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
85
	 * @throws ExecutionException 
86
	 */
87
	@Test
88
	public void testUndo() throws ExecutionException {
89
		operation.undo(null, null);
90
		
91
		Assert.assertEquals(oldHomotypicalGroup, synonym.getHomotypicGroup());
92
	}
93
	
94
	/**
95
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
96
	 * @throws ExecutionException 
97
	 */
98
	@Test
99
	public void testRedo() throws ExecutionException {
100
		operation.redo(null, null);
101
		
102
		Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
103
	}
104

    
105
	/**
106
	 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
107
	 */
108
	@Test
109
	public void testPostExecute() {
110
		// TODO there is not post operation functionality for this class
111
		// at the moment. Implement test when there is.
112
		logger.warn("No post operation functionality for this class");
113
	}
114
}
(3-3/16)