ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / test / java / eu / etaxonomy / taxeditor / editor / name / operation / CreateConceptRelationOperationTest.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.editor.name.operation;
11
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;
17
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;
24
25 /**
26 * @author n.hoffmann
27 * @created 07.04.2009
28 * @version 1.0
29 */
30 public class CreateConceptRelationOperationTest extends AbstractTaxeditorOperationTestBase {
31 private static final Logger logger = Logger
32 .getLogger(CreateConceptRelationOperationTest.class);
33
34 private static TaxonRelationshipType taxonRelationshipType;
35
36 private static Taxon concept;
37
38 /**
39 * @throws java.lang.Exception
40 */
41 @BeforeClass
42 public static void setUpBeforeClass() throws Exception {
43
44 taxon = Taxon.NewInstance(null, null);
45 concept = Taxon.NewInstance(null, null);
46 taxonRelationshipType = TaxonRelationshipType.CONTRADICTION();
47
48 operation = new CreateConceptRelationOperation("Create Concept Relation", null, taxon, concept, taxonRelationshipType, postOperation);
49 }
50
51 /**
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
54 */
55 @Test
56 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
57 operation.execute(monitor, info);
58
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());
61 }
62
63 /**
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
66 */
67 @Test
68 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
69 operation.undo(monitor, info);
70
71 Assert.assertTrue("There should not be taxon relationships", taxon.getTaxonRelations().size() == 0);
72 }
73
74 /**
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
77 */
78 @Test
79 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
80 operation.redo(monitor, info);
81
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());
84 }
85
86 /**
87 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation#postExecute(ICdmBase)}.
88 */
89 @Test
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");
94 }
95 }