#823
[taxeditor.git] / taxeditor-store / src / test / java / eu / etaxonomy / taxeditor / store / operations / DeleteTaxonNodeOperationTest.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.taxon.Taxon;
20 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 import eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation;
22
23 /**
24 * @author n.hoffmann
25 * @created 08.04.2009
26 * @version 1.0
27 */
28 public class DeleteTaxonNodeOperationTest extends AbstractTaxeditorOperationTest{
29 private static final Logger logger = Logger
30 .getLogger(DeleteTaxonNodeOperationTest.class);
31
32 private static Taxon child;
33
34 private static TaxonNode taxonNode;
35
36 /**
37 * @throws java.lang.Exception
38 */
39 @BeforeClass
40 public static void setUpBeforeClass() throws Exception {
41 // TODO get taxon from integration test data
42 taxon = Taxon.NewInstance(null, null);
43
44 child = Taxon.NewInstance(null, null);
45
46 taxon.addTaxonomicChild(child, null, null);
47
48 operation = new DeleteTaxonNodeOperation("Delete Taxon", undoContext, taxonNode, null, null);
49 }
50
51 /**
52 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
53 * @throws ExecutionException
54 */
55 @Test
56 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
57
58 operation.execute(monitor, info);
59
60 Assert.assertTrue(taxon.getTaxonomicChildren().size() == 0);
61 Assert.assertTrue(taxon.getTaxonomicChildrenCount() == 0);
62 }
63
64 /**
65 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
66 * @throws ExecutionException
67 */
68 @Test
69 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
70
71 operation.execute(monitor, info);
72
73 Assert.assertTrue(taxon.getTaxonomicChildren().size() > 0);
74 Assert.assertTrue(taxon.getTaxonomicChildrenCount() > 0);
75 }
76
77 /**
78 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteTaxonNodeOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
79 * @throws ExecutionException
80 */
81 @Test
82 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
83
84 operation.execute(monitor, info);
85
86 Assert.assertTrue(taxon.getTaxonomicChildren().size() == 0);
87 Assert.assertTrue(taxon.getTaxonomicChildrenCount() == 0);
88 }
89 }