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 org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.junit
.Assert
;
15 import org
.junit
.BeforeClass
;
16 import org
.junit
.Test
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
25 public class MoveTaxonOperationTest
extends AbstractTaxeditorOperationTest
{
27 private static Taxon oldParentTaxon
;
28 private static Taxon newParentTaxon
;
31 * @throws java.lang.Exception
34 public static void setUpBeforeClass() throws Exception
{
35 taxon
= Taxon
.NewInstance(null, null);
36 oldParentTaxon
= Taxon
.NewInstance(null, null);
37 newParentTaxon
= Taxon
.NewInstance(null, null);
38 // oldParentTaxon.addTaxonomicChild(taxon, null, null);
39 taxon
.setTaxonomicParent(oldParentTaxon
, null, null);
41 operation
= new MoveTaxonOperation("Move Taxon To Different Parent", undoContext
, taxon
, newParentTaxon
);
45 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
46 * @throws ExecutionException
49 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
50 operation
.execute(monitor
, info
);
52 Assert
.assertEquals(newParentTaxon
,taxon
.getTaxonomicParent());
53 Assert
.assertEquals(taxon
, newParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
54 Assert
.assertTrue(oldParentTaxon
.getTaxonomicChildrenCount() == 0);
59 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
60 * @throws ExecutionException
63 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
64 operation
.undo(monitor
, info
);
66 Assert
.assertEquals(oldParentTaxon
,taxon
.getTaxonomicParent());
67 Assert
.assertTrue(newParentTaxon
.getTaxonomicChildren().size() == 0);
68 Assert
.assertEquals(taxon
, oldParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
72 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.MoveTaxonOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
73 * @throws ExecutionException
76 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
77 operation
.redo(monitor
, info
);
79 Assert
.assertEquals(newParentTaxon
,taxon
.getTaxonomicParent());
80 Assert
.assertEquals(taxon
, newParentTaxon
.getTaxonomicChildren().toArray(new Taxon
[0])[0]);
81 Assert
.assertTrue(oldParentTaxon
.getTaxonomicChildrenCount() == 0);