Merge branch 'release/5.19.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / test / java / eu / etaxonomy / taxeditor / editor / name / operation / CreateSynonymInNewGroupOperationTest.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 package eu.etaxonomy.taxeditor.editor.name.operation;
10
11 import org.eclipse.core.commands.ExecutionException;
12 import org.junit.Assert;
13 import org.junit.BeforeClass;
14 import org.junit.Test;
15
16 import eu.etaxonomy.cdm.model.name.TaxonName;
17 import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
18 import eu.etaxonomy.cdm.model.taxon.Taxon;
19 import eu.etaxonomy.taxeditor.editor.name.operation.CreateSynonymInNewGroupOperation;
20 import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
21
22 /**
23 * @author n.hoffmann
24 * @created 07.04.2009
25 */
26 public class CreateSynonymInNewGroupOperationTest extends AbstractTaxeditorOperationTestBase {
27
28 private static TaxonName newSynonymName;
29
30 @BeforeClass
31 public static void setUpBeforeClass() throws Exception {
32
33 taxon = Taxon.NewInstance(null, null);
34 newSynonymName = TaxonNameFactory.NewNonViralInstance(null);
35
36 operation = new CreateSynonymInNewGroupOperation("Create Synonyma In New Group", undoContext, taxon, newSynonymName, postOperation);
37 }
38
39 @Test
40 public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
41 operation.execute(monitor, info);
42
43 Assert.assertTrue("Taxon should have synonyms now.", taxon.getSynonyms().size() > 0);
44 Assert.assertTrue("Taxon should have a homotypical group now.", taxon.getHomotypicSynonymyGroups().size() > 0);
45 }
46
47 @Test
48 public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
49 operation.undo(monitor, info);
50
51 Assert.assertTrue("Taxon should not have synonyms now.", taxon.getSynonyms().size() == 0);
52 }
53
54 @Test
55 public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
56 operation.redo(monitor, info);
57
58 Assert.assertTrue("Taxon should have synonyms now.", taxon.getSynonyms().size() > 0);
59 Assert.assertTrue("Taxon should have a homotypical group now.", taxon.getHomotypicSynonymyGroups().size() > 0);
60 }
61 }