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
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.junit
.Assert
;
13 import org
.junit
.BeforeClass
;
14 import org
.junit
.Test
;
16 import eu
.etaxonomy
.cdm
.api
.service
.config
.SynonymDeletionConfigurator
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.SynonymType
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
26 public class DeleteSynonymOperationTest
extends AbstractTaxeditorOperationTestBase
{
28 private static Synonym synonym
;
30 private static SynonymType synonymType
;
33 * @throws java.lang.Exception
36 public static void setUpBeforeClass() throws Exception
{
37 taxon
= Taxon
.NewInstance(null, null);
38 synonym
= Synonym
.NewInstance(null, null);
39 synonymType
= SynonymType
.SYNONYM_OF();
41 taxon
.addSynonym(synonym
, synonymType
);
43 operation
= new DeleteSynonymOperation("", undoContext
, new SynonymDeletionConfigurator(), taxon
,synonym
, postOperation
, null, null);
48 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
49 * @throws ExecutionException
52 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
53 operation
.execute(monitor
, info
);
55 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);
59 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
60 * @throws ExecutionException
63 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
64 operation
.undo(monitor
, info
);
66 Assert
.assertTrue(taxon
.getSynonyms().size() > 0);
67 Assert
.assertEquals(synonym
, taxon
.getSynonyms().toArray(new Synonym
[0])[0]);
71 * Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
72 * @throws ExecutionException
75 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
76 operation
.redo(monitor
, info
);
78 Assert
.assertTrue(taxon
.getSynonyms().size() == 0);