3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.store
.operations
;
13 import junit
.framework
.Assert
;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.junit
.BeforeClass
;
18 import org
.junit
.Test
;
20 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
21 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
22 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
32 public class ChangeConceptToSynonymOperationTest
extends AbstractTaxeditorOperationTest
{
33 private static final Logger logger
= Logger
34 .getLogger(ChangeConceptToSynonymOperationTest
.class);
36 private static Taxon taxon
;
38 private static Taxon concept
;
40 private static AbstractPostOperation operation
;
42 private static HomotypicalGroup homotypicalGroup
;
44 private Synonym
[] synonymType
= new Synonym
[0];
45 private Taxon
[] taxonType
= new Taxon
[0];
48 * @throws java.lang.Exception
51 public static void setUpBeforeClass() throws Exception
{
52 taxon
= Taxon
.NewInstance(null, null);
53 concept
= Taxon
.NewInstance(NonViralName
.NewInstance(null), null);
54 homotypicalGroup
= HomotypicalGroup
.NewInstance();
56 concept
.addTaxonRelation(taxon
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR(), null, null);
58 operation
= new ChangeConceptToSynonymOperation("Change misapplication to synonym", null, taxon
, concept
, homotypicalGroup
, postOperation
);
62 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.ChangeConceptToSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
63 * @throws ExecutionException
66 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
67 operation
.execute(null, null);
69 Assert
.assertTrue(taxon
.getSynonyms().size() == 1);
70 Assert
.assertTrue(concept
.getRelationsFromThisTaxon().size() == 0);
71 Assert
.assertEquals(concept
.getName(), taxon
.getSynonyms().toArray(synonymType
)[0].getName());
76 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.ChangeConceptToSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
77 * @throws ExecutionException
80 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
81 operation
.undo(null, null);
83 Assert
.assertTrue("There shouldn't be synonyms after undo operations", taxon
.getSynonyms().size() == 0);
84 Assert
.assertTrue(concept
.getRelationsFromThisTaxon().size() > 0);
85 Assert
.assertEquals(taxon
, concept
.getRelationsFromThisTaxon().toArray(taxonType
)[0]);
89 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.ChangeConceptToSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
90 * @throws ExecutionException
93 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
94 operation
.redo(null, null);
96 Assert
.assertTrue(taxon
.getSynonyms().size() == 1);
97 Assert
.assertTrue(concept
.getRelationsFromThisTaxon().size() == 0);
98 Assert
.assertEquals(concept
.getName(), taxon
.getSynonyms().toArray(synonymType
)[0].getName());
102 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.AbstractPostOperation#postExecute(CdmBase)}.
105 public void testPostExecute() {
106 // TODO there is not post operation functionality for this class
107 // at the moment. Implement test when there is.
108 logger
.warn("No post operation functionality for this class");