50f97726b03f56f993e9a613e29b8753ef4a81d1
[taxeditor.git] / taxeditor-store / src / test / java / eu / etaxonomy / taxeditor / store / operations / DeleteSynonymOperationTest.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 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;
18
19 import eu.etaxonomy.cdm.model.taxon.Synonym;
20 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
21 import eu.etaxonomy.cdm.model.taxon.Taxon;
22
23 /**
24 * @author n.hoffmann
25 * @created 08.04.2009
26 * @version 1.0
27 */
28 public class DeleteSynonymOperationTest extends AbstractTaxeditorOperationTest{
29 private static final Logger logger = Logger
30 .getLogger(DeleteSynonymOperationTest.class);
31
32 private static Synonym synonym;
33
34 private static SynonymRelationshipType synonymRelationshipType;
35
36 /**
37 * @throws java.lang.Exception
38 */
39 @BeforeClass
40 public static void setUpBeforeClass() throws Exception {
41 taxon = Taxon.NewInstance(null, null);
42 synonym = Synonym.NewInstance(null, null);
43 synonymRelationshipType = SynonymRelationshipType.SYNONYM_OF();
44
45 taxon.addSynonym(synonym, synonymRelationshipType);
46
47 operation = new DeleteSynonymOperation("", undoContext, taxon, synonym, postOperation);
48 }
49
50 /**
51 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteSynonymOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
52 * @throws ExecutionException
53 */
54 @Test
55 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
56 operation.execute(monitor, info);
57
58 Assert.assertTrue(taxon.getSynonyms().size() == 0);
59 }
60
61 /**
62 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteSynonymOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
63 * @throws ExecutionException
64 */
65 @Test
66 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
67 operation.undo(monitor, info);
68
69 Assert.assertTrue(taxon.getSynonyms().size() > 0);
70 Assert.assertEquals(synonym, taxon.getSynonyms().toArray(new Synonym[0])[0]);
71 }
72
73 /**
74 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.DeleteSynonymOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
75 * @throws ExecutionException
76 */
77 @Test
78 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
79 operation.redo(monitor, info);
80
81 Assert.assertTrue(taxon.getSynonyms().size() == 0);
82 }
83 }