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
|
|
10
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
11
|
|
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;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
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
|
* @version 1.0
|
26
|
*/
|
27
|
public class DeleteMisapplicationOperationTest extends AbstractTaxeditorOperationTestBase{
|
28
|
private static final Logger logger = Logger
|
29
|
.getLogger(DeleteMisapplicationOperationTest.class);
|
30
|
|
31
|
private static Taxon taxon;
|
32
|
|
33
|
private static Taxon misapplication;
|
34
|
|
35
|
/**
|
36
|
* @throws java.lang.Exception
|
37
|
*/
|
38
|
@BeforeClass
|
39
|
public static void setUpBeforeClass() throws Exception {
|
40
|
|
41
|
taxon = Taxon.NewInstance(null, null);
|
42
|
misapplication = Taxon.NewInstance(null, null);
|
43
|
|
44
|
taxon.addMisappliedName(misapplication, null, null);
|
45
|
|
46
|
operation = new DeleteMisapplicationOperation("", undoContext, null, taxon, misapplication, postOperation, null, null);
|
47
|
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
52
|
* @throws ExecutionException
|
53
|
*/
|
54
|
@Test
|
55
|
public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
|
56
|
operation.execute(monitor, info);
|
57
|
|
58
|
Assert.assertTrue(taxon.getMisappliedNames(false).size() == 0);
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
63
|
* @throws ExecutionException
|
64
|
*/
|
65
|
@Test
|
66
|
public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
|
67
|
operation.undo(monitor, info);
|
68
|
|
69
|
Assert.assertEquals(misapplication, taxon.getMisappliedNames(false).toArray(new Taxon[0])[0]);
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Test method for {@link eu.etaxonomy.taxeditor.editor.name.operation.DeleteMisapplicationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
|
74
|
* @throws ExecutionException
|
75
|
*/
|
76
|
@Test
|
77
|
public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
|
78
|
operation.redo(monitor, info);
|
79
|
|
80
|
Assert.assertTrue(taxon.getMisappliedNames(false).size() == 0);
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
|
85
|
*/
|
86
|
@Test
|
87
|
public void testPostExecute() {
|
88
|
// TODO there is not post operation functionality for this class
|
89
|
// at the moment. Implement test when there is.
|
90
|
logger.warn("No post operation functionality for this class");
|
91
|
}
|
92
|
}
|