3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.store
.operations
;
13 import static org
.junit
.Assert
.*;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.junit
.Assert
;
21 import org
.junit
.BeforeClass
;
22 import org
.junit
.Test
;
24 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
32 public class MoveTaxonOperationTest
extends AbstractTaxeditorOperationTest
{
33 private static final Logger logger
= Logger
34 .getLogger(MoveTaxonOperationTest
.class);
36 private static Taxon oldParentTaxon
;
37 private static Taxon newParentTaxon
;
40 * @throws java.lang.Exception
43 public static void setUpBeforeClass() throws Exception
{
44 taxon
= Taxon
.NewInstance(null, null);
45 oldParentTaxon
= Taxon
.NewInstance(null, null);
46 newParentTaxon
= Taxon
.NewInstance(null, null);
47 // oldParentTaxon.addTaxonomicChild(taxon, null, null);
48 taxon
.setTaxonomicParent(oldParentTaxon
, null, null);
50 operation
= new MoveTaxonOperation("Move Taxon To Different Parent", undoContext
, taxon
, newParentTaxon
);
54 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
55 * @throws ExecutionException
58 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
59 operation
.execute(monitor
, info
);
61 Assert
.assertEquals(newParentTaxon
,taxon
.getTaxonomicParent());
62 Assert
.assertEquals(taxon
, newParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
63 Assert
.assertTrue(oldParentTaxon
.getTaxonomicChildrenCount() == 0);
68 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
69 * @throws ExecutionException
72 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
73 operation
.undo(monitor
, info
);
75 Assert
.assertEquals(oldParentTaxon
,taxon
.getTaxonomicParent());
76 Assert
.assertTrue(newParentTaxon
.getTaxonomicChildren().size() == 0);
77 Assert
.assertEquals(taxon
, oldParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
81 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
82 * @throws ExecutionException
85 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
86 operation
.redo(monitor
, info
);
88 Assert
.assertEquals(newParentTaxon
,taxon
.getTaxonomicParent());
89 Assert
.assertEquals(taxon
, newParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
90 Assert
.assertTrue(oldParentTaxon
.getTaxonomicChildrenCount() == 0);