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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.junit
.Assert
;
15 import org
.junit
.BeforeClass
;
16 import org
.junit
.Test
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.SynonymDeletionConfigurator
;
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
.store
.operations
.AbstractTaxeditorOperationTestBase
;
28 public class DeleteSynonymOperationTest
extends AbstractTaxeditorOperationTestBase
{
29 @SuppressWarnings("unused")
30 private static final Logger logger
= Logger
31 .getLogger(DeleteSynonymOperationTest
.class);
33 private static Synonym synonym
;
35 private static SynonymType synonymType
;
38 * @throws java.lang.Exception
41 public static void setUpBeforeClass() throws Exception
{
42 taxon
= Taxon
.NewInstance(null, null);
43 synonym
= Synonym
.NewInstance(null, null);
44 synonymType
= SynonymType
.SYNONYM_OF();
46 taxon
.addSynonym(synonym
, synonymType
);
48 operation
= new DeleteSynonymOperation("", undoContext
, new SynonymDeletionConfigurator(), taxon
,synonym
, postOperation
, null, null);
53 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
54 * @throws ExecutionException
57 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
58 operation
.execute(monitor
, info
);
60 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);
64 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
65 * @throws ExecutionException
68 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
69 operation
.undo(monitor
, info
);
71 Assert
.assertTrue(taxon
.getSynonyms().size() > 0);
72 Assert
.assertEquals(synonym
, taxon
.getSynonyms().toArray(new Synonym
[0])[0]);
76 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
77 * @throws ExecutionException
80 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
81 operation
.redo(monitor
, info
);
83 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);