Revision d175d20f
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExisitingHomotypicalGroupOperationTest.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
17 | 17 |
|
18 | 18 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
19 | 19 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
20 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
21 | 20 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; |
22 | 21 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
23 | 22 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
24 |
import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation; |
|
25 | 23 |
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase; |
26 | 24 |
|
27 | 25 |
/** |
... | ... | |
31 | 29 |
*/ |
32 | 30 |
public class CreateSynonymInExisitingHomotypicalGroupOperationTest extends AbstractTaxeditorOperationTestBase { |
33 | 31 |
|
34 |
private TaxonNameBase newSynonymName;
|
|
32 |
private NonViralName newSynonymName;
|
|
35 | 33 |
|
36 | 34 |
private HomotypicalGroup homotypicalGroup; |
37 | 35 |
|
38 | 36 |
|
39 | 37 |
private NonViralName<?> taxonName; |
40 |
|
|
38 |
|
|
41 | 39 |
/** |
42 | 40 |
* @throws java.lang.Exception |
43 | 41 |
*/ |
44 | 42 |
@Before |
45 | 43 |
public void setUp() throws Exception { |
46 |
|
|
44 |
|
|
47 | 45 |
taxonName = NonViralName.NewInstance(null); |
48 | 46 |
taxon = Taxon.NewInstance(taxonName, null); |
49 |
|
|
47 |
|
|
50 | 48 |
homotypicalGroup = HomotypicalGroup.NewInstance(); |
51 | 49 |
newSynonymName = NonViralName.NewInstance(null); |
52 |
|
|
50 |
|
|
53 | 51 |
operation = new CreateSynonymInExistingHomotypicalGroupOperation("Create Synonym In Existing Homotypical Group", |
54 | 52 |
undoContext, taxon, homotypicalGroup, newSynonymName, postOperation); |
55 | 53 |
} |
56 | 54 |
|
57 | 55 |
/** |
58 | 56 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
59 |
*
|
|
57 |
* |
|
60 | 58 |
* Homotypic group is the Taxons homotypic group, so we expect the synonym to be homotypic to the accepted taxon. |
61 |
*
|
|
62 |
* @throws ExecutionException
|
|
59 |
* |
|
60 |
* @throws ExecutionException |
|
63 | 61 |
*/ |
64 | 62 |
@Test |
65 |
public void testExecuteTaxonHomotypicGroup() throws ExecutionException {
|
|
63 |
public void testExecuteTaxonHomotypicGroup() throws ExecutionException { |
|
66 | 64 |
homotypicalGroup.addTypifiedName(taxonName); |
67 | 65 |
operation.execute(monitor, info); |
68 |
|
|
66 |
|
|
69 | 67 |
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0); |
70 | 68 |
Assert.assertTrue("Taxon should have a homotypic synonym now", taxon.getHomotypicSynonymsByHomotypicGroup().size() > 0); |
71 | 69 |
} |
72 |
|
|
70 |
|
|
73 | 71 |
/** |
74 | 72 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
75 |
*
|
|
73 |
* |
|
76 | 74 |
* Homotypic group is not the accepted taxons. Heterotypic synonym should be created. |
77 |
*
|
|
78 |
* @throws ExecutionException
|
|
75 |
* |
|
76 |
* @throws ExecutionException |
|
79 | 77 |
*/ |
80 | 78 |
@Test |
81 |
public void testExecuteSynonymHomotypicGroup() throws ExecutionException {
|
|
79 |
public void testExecuteSynonymHomotypicGroup() throws ExecutionException { |
|
82 | 80 |
// test heterotypic synonym |
83 | 81 |
operation.execute(monitor, info); |
84 |
|
|
82 |
|
|
85 | 83 |
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0); |
86 | 84 |
Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0); |
87 | 85 |
Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType()); |
88 | 86 |
} |
89 |
|
|
87 |
|
|
90 | 88 |
|
91 | 89 |
/** |
92 | 90 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
93 |
* @throws ExecutionException
|
|
91 |
* @throws ExecutionException |
|
94 | 92 |
*/ |
95 | 93 |
@Test |
96 | 94 |
public void testUndoTaxonHomotypicGroup() throws ExecutionException { |
97 | 95 |
homotypicalGroup.addTypifiedName(taxonName); |
98 |
|
|
96 |
|
|
99 | 97 |
operation.execute(monitor, info); |
100 | 98 |
operation.undo(monitor, info); |
101 |
|
|
99 |
|
|
102 | 100 |
Assert.assertTrue("There should not be synonym relationships for the taxon", taxon.getSynonyms().size() == 0); |
103 | 101 |
} |
104 |
|
|
102 |
|
|
105 | 103 |
/** |
106 | 104 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
107 |
* @throws ExecutionException
|
|
105 |
* @throws ExecutionException |
|
108 | 106 |
*/ |
109 | 107 |
@Test |
110 | 108 |
public void testUndoSynonymHomotypicGroup() throws ExecutionException { |
111 | 109 |
operation.execute(monitor, info); |
112 | 110 |
operation.undo(monitor, info); |
113 |
|
|
111 |
|
|
114 | 112 |
Assert.assertTrue("There should not be synonym relationships for the taxon", taxon.getSynonyms().size() == 0); |
115 | 113 |
} |
116 | 114 |
|
117 | 115 |
/** |
118 | 116 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
119 |
* @throws ExecutionException
|
|
117 |
* @throws ExecutionException |
|
120 | 118 |
*/ |
121 | 119 |
@Test |
122 | 120 |
public void testRedoTaxonHomotypicGroup() throws ExecutionException { |
123 | 121 |
homotypicalGroup.addTypifiedName(taxonName); |
124 |
|
|
122 |
|
|
125 | 123 |
operation.execute(monitor, info); |
126 |
operation.undo(monitor, info);
|
|
124 |
operation.undo(monitor, info); |
|
127 | 125 |
operation.redo(monitor, info); |
128 |
|
|
126 |
|
|
129 | 127 |
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0); |
130 | 128 |
Assert.assertTrue("Taxon should have a homotypic synonym now", taxon.getHomotypicSynonymsByHomotypicGroup().size() > 0); |
131 | 129 |
} |
132 |
|
|
130 |
|
|
133 | 131 |
/** |
134 | 132 |
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInExistingHomotypicalGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}. |
135 |
* @throws ExecutionException
|
|
133 |
* @throws ExecutionException |
|
136 | 134 |
*/ |
137 | 135 |
@Test |
138 | 136 |
public void testRedoSynonymHomotypicGroup() throws ExecutionException { |
139 | 137 |
operation.execute(monitor, info); |
140 |
operation.undo(monitor, info);
|
|
138 |
operation.undo(monitor, info); |
|
141 | 139 |
operation.redo(monitor, info); |
142 |
|
|
140 |
|
|
143 | 141 |
Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0); |
144 | 142 |
Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0); |
145 | 143 |
Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType()); |
Also available in: Unified diff
added cdm entitysession enabled objects to operations