Project

General

Profile

Download (3.66 KB) Statistics
| Branch: | Tag: | Revision:
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.editor.name.operation;
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.common.ICdmBase;
20
import eu.etaxonomy.cdm.model.taxon.Taxon;
21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
24
import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
25

    
26
/**
27
 * @author n.hoffmann
28
 * @created 07.04.2009
29
 * @version 1.0
30
 */
31
public class CreateConceptRelationOperationTest extends AbstractTaxeditorOperationTestBase {
32
	private static final Logger logger = Logger
33
			.getLogger(CreateConceptRelationOperationTest.class);
34

    
35
	private static TaxonRelationshipType taxonRelationshipType;
36

    
37
	private static Taxon concept;
38

    
39
	/**
40
	 * @throws java.lang.Exception
41
	 */
42
	@BeforeClass
43
	public static void setUpBeforeClass() throws Exception {
44
		
45
		taxon = Taxon.NewInstance(null, null);
46
		concept = Taxon.NewInstance(null, null);
47
		taxonRelationshipType = TaxonRelationshipType.CONTRADICTION();
48
		
49
		operation = new CreateConceptRelationOperation("Create Concept Relation", null, taxon, concept, taxonRelationshipType, postOperation);
50
	}
51

    
52
	/**
53
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
54
	 * @throws ExecutionException 
55
	 */
56
	@Test
57
	public void testExecuteIProgressMonitorIAdaptable() throws ExecutionException {
58
		operation.execute(monitor, info);
59
		
60
		Assert.assertTrue("Taxon should have taxon relationships now.", taxon.getRelationsToThisTaxon().size() > 0);
61
		Assert.assertEquals("Relationship type is not the expected", taxonRelationshipType, taxon.getRelationsToThisTaxon().toArray(new TaxonRelationship[0])[0].getType());
62
	}
63

    
64
	/**
65
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
66
	 * @throws ExecutionException 
67
	 */
68
	@Test
69
	public void testUndoIProgressMonitorIAdaptable() throws ExecutionException {
70
		operation.undo(monitor, info);
71
		
72
		Assert.assertTrue("There should not be taxon relationships", taxon.getTaxonRelations().size() == 0);
73
	}
74
	
75
	/**
76
	 * Test method for {@link eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}.
77
	 * @throws ExecutionException 
78
	 */
79
	@Test
80
	public void testRedoIProgressMonitorIAdaptable() throws ExecutionException {
81
		operation.redo(monitor, info);
82
		
83
		Assert.assertTrue("Taxon should have taxon relationships now.", taxon.getRelationsToThisTaxon().size() > 0);
84
		Assert.assertEquals("Relationship type is not the expected", taxonRelationshipType, taxon.getRelationsToThisTaxon().toArray(new TaxonRelationship[0])[0].getType());
85
	}
86

    
87
	/**
88
	 * Test method for {@link eu.etaxonomy.taxeditor.operation.AbstractPostOperation#postExecute(ICdmBase)}.
89
	 */
90
	@Test
91
	public void testPostExecute() {
92
		// TODO there is not post operation functionality for this class
93
		// at the moment. Implement test when there is.
94
		logger.warn("No post operation functionality for this class");
95
	}
96
}
(8-8/17)