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
.editor
.name
.operation
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.junit
.Assert
;
16 import org
.junit
.BeforeClass
;
17 import org
.junit
.Test
;
19 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
23 import eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.operation
.CreateConceptRelationOperation
;
24 import eu
.etaxonomy
.taxeditor
.store
.operations
.AbstractTaxeditorOperationTest
;
31 public class CreateConceptRelationOperationTest
extends AbstractTaxeditorOperationTest
{
32 private static final Logger logger
= Logger
33 .getLogger(CreateConceptRelationOperationTest
.class);
35 private static TaxonRelationshipType taxonRelationshipType
;
37 private static Taxon concept
;
40 * @throws java.lang.Exception
43 public static void setUpBeforeClass() throws Exception
{
45 taxon
= Taxon
.NewInstance(null, null);
46 concept
= Taxon
.NewInstance(null, null);
47 taxonRelationshipType
= TaxonRelationshipType
.CONTRADICTION();
49 operation
= new CreateConceptRelationOperation("Create Concept Relation", null, taxon
, concept
, taxonRelationshipType
, postOperation
);
53 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#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 should have taxon relationships now.", taxon
.getRelationsToThisTaxon().size() > 0);
61 Assert
.assertEquals("Relationship type is not the expected", taxonRelationshipType
, taxon
.getRelationsToThisTaxon().toArray(new TaxonRelationship
[0])[0].getType());
65 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#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("There should not be taxon relationships", taxon
.getTaxonRelations().size() == 0);
76 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#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 should have taxon relationships now.", taxon
.getRelationsToThisTaxon().size() > 0);
84 Assert
.assertEquals("Relationship type is not the expected", taxonRelationshipType
, taxon
.getRelationsToThisTaxon().toArray(new TaxonRelationship
[0])[0].getType());
88 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostOperation#postExecute(ICdmBase)}.
91 public void testPostExecute() {
92 // TODO there is not post operation functionality for this class
93 // at the moment. Implement test when there is.
94 logger
.warn("No post operation functionality for this class");