Project

General

Profile

Download (3.37 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.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.common.CdmBase;
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

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

    
33
	private static TaxonRelationshipType taxonRelationshipType;
34

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

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

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

    
82
	/**
83
	 * Test method for {@link eu.etaxonomy.taxeditor.store.operations.AbstractPostOperation#postExecute(CdmBase)}.
84
	 */
85
	@Test
86
	public void testPostExecute() {
87
		// TODO there is not post operation functionality for this class
88
		// at the moment. Implement test when there is.
89
		logger.warn("No post operation functionality for this class");
90
	}
91
}
(11-11/22)