Moving editor sources back into trunk
[taxeditor.git] / taxeditor-store / src / test / java / eu / etaxonomy / taxeditor / store / operations / ChangeConceptRelationshipTypeOperationTest.java
1
2 package eu.etaxonomy.taxeditor.store.operations;
3
4 import junit.framework.Assert;
5
6 import org.apache.log4j.Logger;
7 import org.eclipse.core.commands.ExecutionException;
8 import org.junit.BeforeClass;
9 import org.junit.Ignore;
10 import org.junit.Test;
11
12 import eu.etaxonomy.cdm.model.taxon.Taxon;
13 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
14 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
15
16 /**
17 * Specification for changing the concept relation between two taxa
18 *
19 * @author n.hoffmann
20 * @created 07.04.2009
21 * @version 1.0
22 */
23 public class ChangeConceptRelationshipTypeOperationTest extends AbstractTaxeditorOperationTest {
24 private static final Logger logger = Logger
25 .getLogger(ChangeConceptRelationshipTypeOperationTest.class);
26
27
28 private static Taxon relatedTaxon;
29
30 private static TaxonRelationshipType oldRelationshipType;
31
32 private static TaxonRelationshipType newRelationshipType;
33
34 private static TaxonRelationship[] a = new TaxonRelationship[0];
35
36 @BeforeClass
37 public static void setUpBeforeClass() throws Exception {
38 taxon = Taxon.NewInstance(null, null);
39 relatedTaxon = Taxon.NewInstance(null, null);
40 oldRelationshipType = TaxonRelationshipType.OVERLAPS();
41 newRelationshipType = TaxonRelationshipType.OVERLAPS_OR_EXCLUDES();
42
43 taxon.addTaxonRelation(relatedTaxon, oldRelationshipType, null, null);
44 //oldTaxonRelationship = taxon.getTaxonRelations().toArray(a)[0];
45
46 operation = new ChangeConceptRelationshipTypeOperation("Change Concept Relation", null, taxon, relatedTaxon, newRelationshipType, postOperation);
47 }
48
49 @Test
50 @Ignore // Operation not fully implemented
51 public void testExecute() throws ExecutionException {
52 operation.execute(monitor, info);
53
54 Assert.assertEquals(relatedTaxon, taxon.getRelationsFromThisTaxon().toArray(a)[0].getFromTaxon());
55 Assert.assertEquals(newRelationshipType, taxon.getRelationsFromThisTaxon().toArray(a)[0].getType());
56 }
57
58 @Test
59 @Ignore // Operation not fully implemented
60 public void testUndo() throws ExecutionException {
61 operation.undo(monitor, info);
62
63 Assert.assertEquals(relatedTaxon, taxon.getRelationsFromThisTaxon().toArray(a)[0].getFromTaxon());
64 Assert.assertEquals(oldRelationshipType, taxon.getRelationsFromThisTaxon().toArray(a)[0].getType());
65 }
66
67 @Test
68 @Ignore // Operation not fully implemented
69 public void testRedo() throws ExecutionException {
70 operation.redo(monitor, info);
71
72 Assert.assertEquals(relatedTaxon, taxon.getRelationsFromThisTaxon().toArray(a)[0].getFromTaxon());
73 Assert.assertEquals(newRelationshipType, taxon.getRelationsFromThisTaxon().toArray(a)[0].getType());
74 }
75
76 }