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
.api
.service
.config
.SynonymDeletionConfigurator
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
29 public class DeleteSynonymOperationTest
extends AbstractTaxeditorOperationTestBase
{
30 @SuppressWarnings("unused")
31 private static final Logger logger
= Logger
32 .getLogger(DeleteSynonymOperationTest
.class);
34 private static Synonym synonym
;
36 private static SynonymType synonymType
;
39 * @throws java.lang.Exception
42 public static void setUpBeforeClass() throws Exception
{
43 taxon
= Taxon
.NewInstance(null, null);
44 synonym
= Synonym
.NewInstance(null, null);
45 synonymType
= SynonymType
.SYNONYM_OF();
47 taxon
.addSynonym(synonym
, synonymType
);
49 operation
= new DeleteSynonymOperation("", undoContext
, new SynonymDeletionConfigurator(), null, taxon
,synonym
, postOperation
, null, null);
54 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
55 * @throws ExecutionException
58 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
59 operation
.execute(monitor
, info
);
61 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);
65 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
66 * @throws ExecutionException
69 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
70 operation
.undo(monitor
, info
);
72 Assert
.assertTrue(taxon
.getSynonyms().size() > 0);
73 Assert
.assertEquals(synonym
, taxon
.getSynonyms().toArray(new Synonym
[0])[0]);
77 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
78 * @throws ExecutionException
81 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
82 operation
.redo(monitor
, info
);
84 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);