1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
12
|
|
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;
|
18
|
|
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;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created 08.04.2009
|
27
|
*/
|
28
|
public class DeleteSynonymOperationTest extends AbstractTaxeditorOperationTestBase{
|
29
|
@SuppressWarnings("unused")
|
30
|
private static final Logger logger = Logger
|
31
|
.getLogger(DeleteSynonymOperationTest.class);
|
32
|
|
33
|
private static Synonym synonym;
|
34
|
|
35
|
private static SynonymType synonymRelationshipType;
|
36
|
|
37
|
/**
|
38
|
* @throws java.lang.Exception
|
39
|
*/
|
40
|
@BeforeClass
|
41
|
public static void setUpBeforeClass() throws Exception {
|
42
|
taxon = Taxon.NewInstance(null, null);
|
43
|
synonym = Synonym.NewInstance(null, null);
|
44
|
synonymRelationshipType = SynonymType.SYNONYM_OF();
|
45
|
|
46
|
taxon.addSynonym(synonym, synonymRelationshipType);
|
47
|
|
48
|
operation = new DeleteSynonymOperation("", undoContext, taxon, synonym, postOperation);
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
53
|
* @throws ExecutionException
|
54
|
*/
|
55
|
@Test
|
56
|
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
|
57
|
operation.execute(monitor, info);
|
58
|
|
59
|
Assert.assertTrue(taxon.getSynonyms().size() == 0);
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
64
|
* @throws ExecutionException
|
65
|
*/
|
66
|
@Test
|
67
|
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
|
68
|
operation.undo(monitor, info);
|
69
|
|
70
|
Assert.assertTrue(taxon.getSynonyms().size() > 0);
|
71
|
Assert.assertEquals(synonym, taxon.getSynonyms().toArray(new Synonym[0])[0]);
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
76
|
* @throws ExecutionException
|
77
|
*/
|
78
|
@Test
|
79
|
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
|
80
|
operation.redo(monitor, info);
|
81
|
|
82
|
Assert.assertTrue(taxon.getSynonyms().size() == 0);
|
83
|
}
|
84
|
}
|