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 static org
.junit
.Assert
.*;
15 import org
.apache
.log4j
.Logger
;
16 import org
.eclipse
.core
.commands
.ExecutionException
;
17 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
18 import org
.eclipse
.core
.runtime
.IAdaptable
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.junit
.Assert
;
21 import org
.junit
.BeforeClass
;
22 import org
.junit
.Test
;
24 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
25 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
26 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
34 public class DeleteDescriptionElementOperationTest
extends AbstractTaxeditorOperationTest
{
35 private static final Logger logger
= Logger
36 .getLogger(DeleteDescriptionElementOperationTest
.class);
38 private static DescriptionElementBase descriptionElement
;
40 private static TaxonDescription description
;
43 * @throws java.lang.Exception
46 public static void setUpBeforeClass() throws Exception
{
47 taxon
= Taxon
.NewInstance(null, null);
48 descriptionElement
= TextData
.NewInstance();
50 description
= TaxonDescription
.NewInstance();
52 description
.addElement(descriptionElement
);
54 taxon
.addDescription(description
);
57 operation
= new DeleteDescriptionElementOperation("", undoContext
, taxon
, descriptionElement
, postOperation
);
61 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
62 * @throws ExecutionException
65 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
66 operation
.execute(monitor
, info
);
68 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);
72 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
73 * @throws ExecutionException
76 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException
{
77 operation
.undo(monitor
, info
);
79 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() > 0);
80 Assert
.assertEquals(descriptionElement
, taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().toArray(new DescriptionElementBase
[0])[0]);
84 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteDescriptionElementOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
85 * @throws ExecutionException
88 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
89 operation
.redo(monitor
, info
);
91 Assert
.assertTrue(taxon
.getDescriptions().toArray(new TaxonDescription
[0])[0].getElements().size() == 0);