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
.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
.operations
.DeleteDescriptionElementOperation
;
29 public class DeleteDescriptionElementOperationTest
extends AbstractTaxeditorOperationTest
{
31 private static DescriptionElementBase descriptionElement
;
33 private static TaxonDescription description
;
36 * @throws java.lang.Exception
39 public static void setUpBeforeClass() throws Exception
{
40 taxon
= Taxon
.NewInstance(null, null);
41 descriptionElement
= TextData
.NewInstance();
43 description
= TaxonDescription
.NewInstance();
45 description
.addElement(descriptionElement
);
47 taxon
.addDescription(description
);
50 operation
= new DeleteDescriptionElementOperation("", undoContext
, taxon
, descriptionElement
, postOperation
);
54 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteDescriptionElementOperation#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
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);
65 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
66 * @throws ExecutionException
69 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
70 operation
.undo(monitor
, info
);
72 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() > 0);
73 Assert
.assertEquals(descriptionElement
, taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().toArray(new DescriptionElementBase
[0])[0]);
77 * Test method for {@link eu.etaxonomy.taxeditor.operations.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
78 * @throws ExecutionException
81 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
82 operation
.redo(monitor
, info
);
84 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);