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
.editor
.name
.operation
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.junit
.Assert
;
16 import org
.junit
.BeforeClass
;
17 import org
.junit
.Test
;
19 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
25 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
32 public class ChangeSynonymToMisapplicationOperationTest
extends AbstractTaxeditorOperationTestBase
{
33 private static final Logger logger
= Logger
34 .getLogger(ChangeSynonymToMisapplicationOperationTest
.class);
36 private static Synonym synonym
;
38 private static Taxon taxon
;
40 private static AbstractPostOperation operation
;
42 private static SynonymType synonymType
;
45 * @throws java.lang.Exception
48 public static void setUpBeforeClass() throws Exception
{
49 taxon
= Taxon
.NewInstance(null, null);
50 synonym
= Synonym
.NewInstance(NonViralName
.NewInstance(null), null);
51 synonymType
= SynonymType
.SYNONYM_OF();
52 taxon
.addSynonym(synonym
, synonymType
);
54 operation
= new ChangeSynonymToMisapplicationOperation("Change Synonym To Misapplication", null, taxon
, synonym
, postOperation
);
58 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
59 * @throws ExecutionException
62 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
63 operation
.execute(null, null);
65 Assert
.assertTrue("Synonym should be deleted from taxon", taxon
.getSynonyms().size() == 0);
66 Assert
.assertTrue("Taxon should have misapplications", taxon
.getMisappliedNames().size() > 0);
67 Assert
.assertEquals("The name of synonym and misapplication should be equal", synonym
.getName(), taxon
.getMisappliedNames().toArray(new Taxon
[0])[0].getName());
71 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
72 * @throws ExecutionException
75 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
76 operation
.undo(null, null);
78 Assert
.assertTrue("Taxon should have synonyms.", taxon
.getSynonyms().size() > 0);
79 Assert
.assertTrue("Taxon should not have taxon relationship.", taxon
.getTaxonRelations().size() == 0);
80 Assert
.assertEquals("Not the expected synonym.", synonym
, taxon
.getSynonyms().toArray(new Synonym
[0])[0]);
81 Assert
.assertEquals("SynonymRelationshipType is not the expected.", synonymType
, taxon
.getSynonyms().iterator().next().getType());
85 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
86 * @throws ExecutionException
89 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
90 operation
.redo(null, null);
92 Assert
.assertTrue("Synonym should be deleted from taxon", taxon
.getSynonyms().size() == 0);
93 Assert
.assertTrue("Taxon should have misapplications", taxon
.getMisappliedNames().size() > 0);
94 Assert
.assertEquals("The name of synonym and misapplication should be equal", synonym
.getName(), taxon
.getMisappliedNames().toArray(new Taxon
[0])[0].getName());
98 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
101 public void testPostExecute() {
102 // TODO there is not post operation functionality for this class
103 // at the moment. Implement test when there is.
104 logger
.warn("No post operation functionality for this class");