Moving editor sources back into trunk
[taxeditor.git] / taxeditor-store / src / test / java / eu / etaxonomy / taxeditor / store / operations / DeleteConceptRelationOperationTest.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
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.
9 */
10
11 package eu.etaxonomy.taxeditor.store.operations;
12
13 import static org.junit.Assert.*;
14
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;
23
24 import eu.etaxonomy.cdm.model.common.CdmBase;
25 import eu.etaxonomy.cdm.model.taxon.Taxon;
26 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
27
28 /**
29 * @author n.hoffmann
30 * @created 08.04.2009
31 * @version 1.0
32 */
33 public class DeleteConceptRelationOperationTest extends AbstractTaxeditorOperationTest{
34 private static final Logger logger = Logger
35 .getLogger(DeleteConceptRelationOperationTest.class);
36
37 private static TaxonRelationshipType relationshipType;
38
39 private static Taxon relatedTaxon;
40
41 /**
42 * @throws java.lang.Exception
43 */
44 @BeforeClass
45 public static void setUpBeforeClass() throws Exception {
46
47 taxon = Taxon.NewInstance(null, null);
48 relatedTaxon = Taxon.NewInstance(null, null);
49 relationshipType = TaxonRelationshipType.CONTRADICTION();
50
51 taxon.addTaxonRelation(relatedTaxon, relationshipType, null, null);
52
53 Assert.assertTrue(taxon.getTaxonRelations().size() > 0);
54
55 operation = new DeleteConceptRelationOperation("", undoContext, taxon, relatedTaxon, postOperation);
56 }
57
58 /**
59 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
60 * @throws ExecutionException
61 */
62 @Test
63 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
64 operation.execute(monitor, info);
65
66 Assert.assertTrue(taxon.getTaxonRelations().size() == 0);
67 }
68
69 /**
70 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
71 * @throws ExecutionException
72 */
73 @Test
74 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
75 operation.undo(monitor, info);
76
77 Assert.assertTrue(taxon.getTaxonRelations().size() > 0);
78 }
79
80 /**
81 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
82 * @throws ExecutionException
83 */
84 @Test
85 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
86 operation.redo(monitor, info);
87
88 Assert.assertTrue(taxon.getTaxonRelations().size() == 0);
89 }
90
91 /**
92 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.AbstractPostOperation#postExecute(CdmBase)}.
93 */
94 @Test
95 public void testPostExecute() {
96 // TODO there is not post operation functionality for this class
97 // at the moment. Implement test when there is.
98 logger.warn("No post operation functionality for this class");
99 }
100 }