2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
11 import org
.apache
.log4j
.Logger
;
12 import org
.eclipse
.core
.commands
.ExecutionException
;
13 import org
.junit
.Assert
;
14 import org
.junit
.BeforeClass
;
15 import org
.junit
.Test
;
17 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
18 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameFactory
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
23 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
29 public class ChangeSynonymToMisapplicationOperationTest
extends AbstractTaxeditorOperationTestBase
{
31 private static final Logger logger
= Logger
.getLogger(ChangeSynonymToMisapplicationOperationTest
.class);
33 private static AbstractPostOperation
<Taxon
> operation
;
35 private static Synonym synonym
;
36 private static Taxon taxon
;
37 private static SynonymType synonymType
;
40 public static void setUpBeforeClass() throws Exception
{
41 taxon
= Taxon
.NewInstance(null, null);
42 synonym
= Synonym
.NewInstance(TaxonNameFactory
.NewNonViralInstance(null), null);
43 synonymType
= SynonymType
.SYNONYM_OF();
44 taxon
.addSynonym(synonym
, synonymType
);
46 operation
= new ChangeSynonymToMisapplicationOperation("Change Synonym To Misapplication", null, taxon
, synonym
, postOperation
);
50 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
51 operation
.execute(null, null);
53 Assert
.assertTrue("Synonym should be deleted from taxon", taxon
.getSynonyms().size() == 0);
54 Assert
.assertTrue("Taxon should have misapplications", taxon
.getMisappliedNames(false).size() > 0);
55 Assert
.assertEquals("The name of synonym and misapplication should be equal", synonym
.getName(), taxon
.getMisappliedNames(false).toArray(new Taxon
[0])[0].getName());
59 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
60 operation
.undo(null, null);
62 Assert
.assertTrue("Taxon should have synonyms.", taxon
.getSynonyms().size() > 0);
63 Assert
.assertTrue("Taxon should not have taxon relationship.", taxon
.getTaxonRelations().size() == 0);
64 Assert
.assertEquals("Not the expected synonym.", synonym
, taxon
.getSynonyms().toArray(new Synonym
[0])[0]);
65 Assert
.assertEquals("SynonymType is not the expected.", synonymType
, taxon
.getSynonyms().iterator().next().getType());
69 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
70 operation
.redo(null, null);
72 Assert
.assertTrue("Synonym should be deleted from taxon", taxon
.getSynonyms().size() == 0);
73 Assert
.assertTrue("Taxon should have misapplications", taxon
.getMisappliedNames(false).size() > 0);
74 Assert
.assertEquals("The name of synonym and misapplication should be equal", synonym
.getName(), taxon
.getMisappliedNames(false).toArray(new Taxon
[0])[0].getName());
78 public void testPostExecute() {
79 // TODO there is not post operation functionality for this class
80 // at the moment. Implement test when there is.
81 logger
.warn("No post operation functionality for this class");