editor now updatable via updateSite
[taxeditor.git] / taxeditor-store / src / test / java / eu / etaxonomy / taxeditor / store / operations / DeleteMisapplicationOperationTest.java
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.store.operations;
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.common.CdmBase;
20 import eu.etaxonomy.cdm.model.taxon.Taxon;
21
22 /**
23 * @author n.hoffmann
24 * @created 08.04.2009
25 * @version 1.0
26 */
27 public class DeleteMisapplicationOperationTest extends AbstractTaxeditorOperationTest{
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, taxon, misapplication, postOperation);
47 }
48
49 /**
50 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteMisapplicationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
51 * @throws ExecutionException
52 */
53 @Test
54 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
55 operation.execute(monitor, info);
56
57 Assert.assertTrue(taxon.getMisappliedNames().size() == 0);
58 }
59
60 /**
61 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteMisapplicationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
62 * @throws ExecutionException
63 */
64 @Test
65 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
66 operation.undo(monitor, info);
67
68 Assert.assertEquals(misapplication, taxon.getMisappliedNames().toArray(new Taxon[0])[0]);
69 }
70
71 /**
72 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteMisapplicationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
73 * @throws ExecutionException
74 */
75 @Test
76 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
77 operation.redo(monitor, info);
78
79 Assert.assertTrue(taxon.getMisappliedNames().size() == 0);
80 }
81
82 /**
83 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.AbstractPostOperation#postExecute(CdmBase)}.
84 */
85 @Test
86 public void testPostExecute() {
87 // TODO there is not post operation functionality for this class
88 // at the moment. Implement test when there is.
89 logger.warn("No post operation functionality for this class");
90 }
91 }