Project

General

Profile

« Previous | Next » 

Revision d175d20f

Added by Cherian Mathew almost 9 years ago

added cdm entitysession enabled objects to operations

View differences:

eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperationTest.java
1 1
/**
2 2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
26 26
import eu.etaxonomy.cdm.model.taxon.Taxon;
27 27
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
28 28
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
29
import eu.etaxonomy.taxeditor.editor.name.operation.SwapSynonymAndAcceptedOperation;
30 29
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
31 30
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
32 31

  
......
38 37
public class SwapSynonymAndAcceptedOperationTest extends AbstractTaxeditorOperationTestBase {
39 38
	private static final Logger logger = Logger
40 39
			.getLogger(SwapSynonymAndAcceptedOperationTest.class);
41
	
40

  
42 41
	private static AbstractPostOperation operation;
43 42

  
44 43
	private static Taxon taxon;
......
65 64

  
66 65
	private static NonViralName<?> oldTaxonName;
67 66

  
68
	
67

  
69 68
	/**
70 69
	 * @throws java.lang.Exception
71 70
	 */
72 71
	@BeforeClass
73 72
	public static void setUpBeforeClass() throws Exception {
74
		
73

  
75 74
		(new DefaultTermInitializer()).initialize();
76
		
75

  
77 76
		// Create the original accepted taxon
78 77
		oldTaxonName = NonViralName.NewInstance(null);
79 78
		taxon = Taxon.NewInstance(oldTaxonName, null);
80
		
79

  
81 80
		// Create its parent taxon
82 81
		parentTaxon = Taxon.NewInstance(NonViralName.NewInstance(null), null);
83 82
		parentTaxon.addTaxonomicChild(taxon, null, null);
......
85 84
		// Give it a child taxon
86 85
		childTaxon = Taxon.NewInstance(NonViralName.NewInstance(null), null);
87 86
		childTaxon.setTaxonomicParent(taxon, null, null);
88
		
87

  
89 88
		// Create a homotypic synonym for the accepted taxon
90 89
		taxon.addHomotypicSynonymName(NonViralName.NewInstance(null), null, null);
91 90
//		homotypicSynonym = Synonym.NewInstance(NonViralName.NewInstance(null), null);
92 91
//		HomotypicalGroup acceptedHomotypicalGroup = HomotypicalGroup.NewInstance();
93 92
//		acceptedHomotypicalGroup.addTypifiedName(oldTaxon.getName());
94 93
//		acceptedHomotypicalGroup.addTypifiedName(homotypicSynonym.getName());
95
		
94

  
96 95
		// Create a heterotypic synonym that will be used to create the new accepted taxon
97 96
		oldSynonymName = NonViralName.NewInstance(null);
98 97
		oldHeterotypicSynonym = Synonym.NewInstance(oldSynonymName, null);
......
100 99
		heteroypicalGroup = HomotypicalGroup.NewInstance();
101 100
		heteroypicalGroup.addTypifiedName(oldHeterotypicSynonym.getName());
102 101
		taxon.addSynonym(oldHeterotypicSynonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
103
		
102

  
104 103
		// Create a misapplication
105 104
		misapplication = Taxon.NewInstance(NonViralName.NewInstance(null), null);
106
		taxon.addMisappliedName(misapplication, null, null);	
107
		
105
		taxon.addMisappliedName(misapplication, null, null);
106

  
108 107
		// Create a concept relation
109 108
		concept = Taxon.NewInstance(NonViralName.NewInstance(null), null);
110 109
		conceptRelationshipType = TaxonRelationshipType.CONGRUENT_TO();
111
		concept.addTaxonRelation(taxon, conceptRelationshipType, null, null);	
112
		
110
		concept.addTaxonRelation(taxon, conceptRelationshipType, null, null);
111

  
113 112
		// Create a description
114 113
		description = TaxonDescription.NewInstance();
115 114
		taxon.addDescription(description);
116
		
115

  
117 116
		operation = new SwapSynonymAndAcceptedOperation
118
				(null, undoContext, taxon, oldHeterotypicSynonym, postOperation);
117
				(null, undoContext, taxon, oldHeterotypicSynonym, postOperation, cdmEntitySessionEnabled);
119 118
	}
120 119

  
121 120

  
122 121
	/**
123 122
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
124
	 * @throws ExecutionException 
123
	 * @throws ExecutionException
125 124
	 */
126 125
	@Test
127 126
	public void testExecute() throws ExecutionException {
128 127
		operation.execute(null, null);
129
		
130
		// New taxon has correct name?		
128

  
129
		// New taxon has correct name?
131 130
		Assert.assertEquals(taxon.getName(), oldSynonymName);
132
		
131

  
133 132
		// New taxon has correct parent?
134 133
		Assert.assertEquals(taxon.getTaxonomicParent(), parentTaxon);
135
		
134

  
136 135
		// New taxon has correct child?
137 136
		Assert.assertTrue(taxon.getTaxonomicChildren().contains(childTaxon));
138
		
137

  
139 138
		// New taxon has 2 synonyms?
140 139
		Assert.assertEquals(taxon.getSynonyms().size(), 2);
141
		
140

  
142 141
		// New taxon has a synonym with the name of the previous accepted taxon?
143 142
		Assert.assertTrue(taxon.getSynonymNames().contains(oldTaxonName));
144
		
143

  
145 144
		// New taxon has misapplication?
146 145
		Assert.assertTrue(taxon.getMisappliedNames().contains(misapplication));
147
		
146

  
148 147
		// New taxon has 1 concept relation?
149 148
		int conceptRelCount = 0;
150 149
		for (TaxonRelationship relation : taxon.getTaxonRelations()) {
......
155 154
			conceptRelCount++;
156 155
		}
157 156
		Assert.assertEquals(conceptRelCount, 1);
158
		
157

  
159 158
		// New taxon has description?
160 159
		taxon.getDescriptions().contains(description);
161 160
	}
162 161

  
163 162
	/**
164 163
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
165
	 * @throws ExecutionException 
164
	 * @throws ExecutionException
166 165
	 */
167 166
	@Test
168 167
	public void testUndo() throws ExecutionException {
169 168
		operation.undo(null, null);
170
		
169

  
171 170
//		Assert.assertEquals(oldHomotypicalGroup, synonym.getHomotypicGroup());
172 171
	}
173
	
172

  
174 173
	/**
175 174
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeHomotypicGroupOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
176
	 * @throws ExecutionException 
175
	 * @throws ExecutionException
177 176
	 */
178 177
	@Test
179 178
	public void testRedo() throws ExecutionException {
180 179
		operation.redo(null, null);
181
		
180

  
182 181
//		Assert.assertEquals(newHomotypicalGroup, synonym.getHomotypicGroup());
183 182
	}
184 183

  

Also available in: Unified diff