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