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
;
28 public class DeleteDescriptionElementOperationTest
extends AbstractTaxeditorOperationTest
{
30 private static DescriptionElementBase descriptionElement
;
32 private static TaxonDescription description
;
35 * @throws java.lang.Exception
38 public static void setUpBeforeClass() throws Exception
{
39 taxon
= Taxon
.NewInstance(null, null);
40 descriptionElement
= TextData
.NewInstance();
42 description
= TaxonDescription
.NewInstance();
44 description
.addElement(descriptionElement
);
46 taxon
.addDescription(description
);
49 operation
= new DeleteDescriptionElementOperation("", undoContext
, taxon
, descriptionElement
, postOperation
);
53 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
54 * @throws ExecutionException
57 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
58 operation
.execute(monitor
, info
);
60 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);
64 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
65 * @throws ExecutionException
68 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
69 operation
.undo(monitor
, info
);
71 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() > 0);
72 Assert
.assertEquals(descriptionElement
, taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().toArray(new DescriptionElementBase
[0])[0]);
76 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
77 * @throws ExecutionException
80 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
81 operation
.redo(monitor
, info
);
83 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);