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 org.eclipse.core.commands.ExecutionException;
|
13
|
import org.junit.Assert;
|
14
|
import org.junit.BeforeClass;
|
15
|
import org.junit.Test;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
|
19
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
20
|
import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation;
|
21
|
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created 07.04.2009
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class CreateSynonymInNewGroupOperationTest extends AbstractTaxeditorOperationTestBase {
|
29
|
|
30
|
private static TaxonName newSynonymName;
|
31
|
|
32
|
/**
|
33
|
* @throws java.lang.Exception
|
34
|
*/
|
35
|
@BeforeClass
|
36
|
public static void setUpBeforeClass() throws Exception {
|
37
|
|
38
|
taxon = Taxon.NewInstance(null, null);
|
39
|
newSynonymName = TaxonNameFactory.NewNonViralInstance(null);
|
40
|
|
41
|
operation = new CreateSynonymInNewGroupOperation("Create Synonyma In New Group", undoContext, taxon, newSynonymName, postOperation);
|
42
|
}
|
43
|
|
44
|
/**
|
45
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
46
|
* @throws ExecutionException
|
47
|
*/
|
48
|
@Test
|
49
|
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
|
50
|
operation.execute(monitor, info);
|
51
|
|
52
|
Assert.assertTrue("Taxon should have synonyms now.", taxon.getSynonyms().size() > 0);
|
53
|
Assert.assertTrue("Taxon should have a homotypical group now.", taxon.getHomotypicSynonymyGroups().size() > 0);
|
54
|
}
|
55
|
|
56
|
/**
|
57
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
58
|
* @throws ExecutionException
|
59
|
*/
|
60
|
@Test
|
61
|
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
|
62
|
operation.undo(monitor, info);
|
63
|
|
64
|
Assert.assertTrue("Taxon should not have synonyms now.", taxon.getSynonyms().size() == 0);
|
65
|
}
|
66
|
|
67
|
/**
|
68
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
69
|
* @throws ExecutionException
|
70
|
*/
|
71
|
@Test
|
72
|
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
|
73
|
operation.redo(monitor, info);
|
74
|
|
75
|
Assert.assertTrue("Taxon should have synonyms now.", taxon.getSynonyms().size() > 0);
|
76
|
Assert.assertTrue("Taxon should have a homotypical group now.", taxon.getHomotypicSynonymyGroups().size() > 0);
|
77
|
|
78
|
}
|
79
|
}
|