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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
12 import org
.apache
.log4j
.Logger
;
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
.common
.ICdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
22 import eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.operation
.CreateConceptRelationOperation
;
23 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTestBase
;
30 public class CreateConceptRelationOperationTest
extends AbstractTaxeditorOperationTestBase
{
31 private static final Logger logger
= Logger
32 .getLogger(CreateConceptRelationOperationTest
.class);
34 private static TaxonRelationshipType taxonRelationshipType
;
36 private static Taxon concept
;
39 * @throws java.lang.Exception
42 public static void setUpBeforeClass() throws Exception
{
44 taxon
= Taxon
.NewInstance(null, null);
45 concept
= Taxon
.NewInstance(null, null);
46 taxonRelationshipType
= TaxonRelationshipType
.CONTRADICTION();
48 operation
= new CreateConceptRelationOperation("Create Concept Relation", null, taxon
, concept
, taxonRelationshipType
, postOperation
);
52 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
53 * @throws ExecutionException
56 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException
{
57 operation
.execute(monitor
, info
);
59 Assert
.assertTrue("Taxon should have taxon relationships now.", taxon
.getRelationsToThisTaxon().size() > 0);
60 Assert
.assertEquals("Relationship type is not the expected", taxonRelationshipType
, taxon
.getRelationsToThisTaxon().toArray(new TaxonRelationship
[0])[0].getType());
64 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#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("There should not be taxon relationships", taxon
.getTaxonRelations().size() == 0);
75 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
76 * @throws ExecutionException
79 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException
{
80 operation
.redo(monitor
, info
);
82 Assert
.assertTrue("Taxon should have taxon relationships now.", taxon
.getRelationsToThisTaxon().size() > 0);
83 Assert
.assertEquals("Relationship type is not the expected", taxonRelationshipType
, taxon
.getRelationsToThisTaxon().toArray(new TaxonRelationship
[0])[0].getType());
87 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
90 public void testPostExecute() {
91 // TODO there is not post operation functionality for this class
92 // at the moment. Implement test when there is.
93 logger
.warn("No post operation functionality for this class");