Project

General

Profile

Download (2.7 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2011 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.cdm.model.description;
10

    
11
import java.util.List;
12

    
13
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
14
import org.junit.Assert;
15
import org.junit.Test;
16

    
17
import eu.etaxonomy.cdm.model.term.DefinedTerm;
18
import eu.etaxonomy.cdm.model.term.TermType;
19
import eu.etaxonomy.cdm.model.term.TermVocabulary;
20
import eu.etaxonomy.cdm.test.unit.EntityTestBase;
21

    
22
/**
23
 * @author k.luther
24
 * @since 11.04.2011
25
 */
26
public class DescriptionElementTest extends EntityTestBase {
27

    
28
    @SuppressWarnings("unused")
29
    private static Logger logger = LogManager.getLogger(DescriptionElementTest.class);
30

    
31
/* ************************** TESTS **********************************************************/
32

    
33
	@Test
34
	public void testGetModifiersVocabulary(){
35
		TaxonDescription desc = TaxonDescription.NewInstance();
36
		CategoricalData data = CategoricalData.NewInstance();
37
		desc.addElement(data);
38
		StateData stateData = StateData.NewInstance();
39
		data.addStateData(stateData);
40

    
41
		TermType modifierType = TermType.Modifier;
42
		TermVocabulary<DefinedTerm> plantPartVoc = TermVocabulary.NewInstance(modifierType,
43
		        DefinedTerm.class, "plant parts", "plant parts", "parts", null);
44
		DefinedTerm leaf = DefinedTerm.NewModifierInstance("leaf", "leaf", null);
45
		plantPartVoc.addTerm(leaf);
46
		data.addModifier(leaf);
47
		DefinedTerm peduncle = DefinedTerm.NewModifierInstance("peduncle", "peduncle", null);
48
		plantPartVoc.addTerm(peduncle);
49
		data.addModifier(peduncle);
50
		DefinedTerm notExistingPart = DefinedTerm.NewModifierInstance("not existing part", "not existing part", null);
51
		plantPartVoc.addTerm(notExistingPart);
52

    
53
		TermVocabulary<DefinedTerm> ethnicGroupVoc = TermVocabulary.NewInstance(TermType.Modifier,
54
		        DefinedTerm.class, "An ethnic group", "ethnic group", null, null);
55
		DefinedTerm scots = DefinedTerm.NewModifierInstance("Scots ", "Scots", null);
56
		ethnicGroupVoc.addTerm(scots);
57
		data.addModifier(scots);
58

    
59
		List<DefinedTerm> modifiers = data.getModifiers(plantPartVoc);
60
		Assert.assertEquals("There should be 2 modifiers of type 'plant part'", 2, modifiers.size());
61
		Assert.assertEquals("There should be 3 terms in the 'plant part' vocabulary", 3, plantPartVoc.size());
62
		Assert.assertEquals("There should be 1 modifiers of type 'ethnic group'", 1, data.getModifiers(ethnicGroupVoc).size());
63
		Assert.assertEquals("There should be 3 modifiers all together", 3, data.getModifiers().size());
64
	}
65
}
(2-2/9)