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
.editor
.name
.operation
;
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
.description
.DescriptionElementBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
20 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
22 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
.DeleteDescriptionElementOperation
;
23 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
30 public class DeleteDescriptionElementOperationTest
extends AbstractTaxeditorOperationTestBase
{
32 private static DescriptionElementBase descriptionElement
;
34 private static TaxonDescription description
;
37 * @throws java.lang.Exception
40 public static void setUpBeforeClass() throws Exception
{
41 taxon
= Taxon
.NewInstance(null, null);
42 descriptionElement
= TextData
.NewInstance();
44 description
= TaxonDescription
.NewInstance();
46 description
.addElement(descriptionElement
);
48 taxon
.addDescription(description
);
51 operation
= new DeleteDescriptionElementOperation("", undoContext
, descriptionElement
, postOperation
, cdmEntitySessionEnabled
);
55 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
56 * @throws ExecutionException
59 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
60 operation
.execute(monitor
, info
);
62 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);
66 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
67 * @throws ExecutionException
70 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
71 operation
.undo(monitor
, info
);
73 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() > 0);
74 Assert
.assertEquals(descriptionElement
, taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().toArray(new DescriptionElementBase
[0])[0]);
78 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.descriptive.operation.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
79 * @throws ExecutionException
82 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
83 operation
.redo(monitor
, info
);
85 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);