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