2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
11 import org
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.junit
.Assert
;
13 import org
.junit
.BeforeClass
;
14 import org
.junit
.Test
;
16 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
17 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
18 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.operation
.DeleteDescriptionElementOperation
;
21 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
27 public class DeleteDescriptionElementOperationTest
extends AbstractTaxeditorOperationTestBase
{
29 private static DescriptionElementBase descriptionElement
;
30 private static TaxonDescription description
;
33 public static void setUpBeforeClass() throws Exception
{
34 taxon
= Taxon
.NewInstance(null, null);
35 descriptionElement
= TextData
.NewInstance();
36 description
= TaxonDescription
.NewInstance();
37 description
.addElement(descriptionElement
);
38 taxon
.addDescription(description
);
40 operation
= new DeleteDescriptionElementOperation("", undoContext
, descriptionElement
, postOperation
, cdmEntitySessionEnabled
);
44 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
45 operation
.execute(monitor
, info
);
46 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);
50 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
51 operation
.undo(monitor
, info
);
53 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() > 0);
54 Assert
.assertEquals(descriptionElement
, taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().toArray(new DescriptionElementBase
[0])[0]);
58 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
59 operation
.redo(monitor
, info
);
60 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);