Project

General

Profile

« Previous | Next » 

Revision 90046bc4

Added by Andreas Müller almost 8 years ago

Remove generics from Reference in cdmlib-model #5830

View differences:

cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/description/DescriptionElementTest.java
1 1
/**
2 2
* Copyright (C) 2011 EDIT
3
* European Distributed Institute of Taxonomy 
3
* European Distributed Institute of Taxonomy
4 4
* http://www.e-taxonomy.eu
5
* 
5
*
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
......
47 47
@SuppressWarnings("unused")
48 48
private static Logger logger = Logger.getLogger(DescriptionElementTest.class);
49 49

  
50
	
50

  
51 51
	private CategoricalData categorialData;
52 52
	private IndividualsAssociation indAssociation;
53 53
	private QuantitativeData quantData;
54 54
	private Taxon taxon;
55 55
	private TaxonInteraction taxonInteraction;
56
	
56

  
57 57
	@BeforeClass
58 58
	public static void setUpBeforeClass() {
59 59
		DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
......
68 68
		categorialData = CategoricalData.NewInstance();
69 69
		Media media = Media.NewInstance(null, 1000, "jpeg", null);
70 70
		categorialData.addMedia(media);
71
		
71

  
72 72
		DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.Unknown);
73
		Reference<?> citation = ReferenceFactory.newArticle();
73
		Reference citation = ReferenceFactory.newArticle();
74 74
		citation.setTitle("Test");
75 75
		source.setCitation(citation);
76 76
		categorialData.addSource(source );
77 77
		StateData state = StateData.NewInstance();
78 78
		categorialData.addStateData(state);
79
		
79

  
80 80
		indAssociation = IndividualsAssociation.NewInstance();
81
		
81

  
82 82
		DerivedUnit associatedSpecimen = DerivedUnit.NewPreservedSpecimenInstance();
83 83
		associatedSpecimen.setIndividualCount(2);
84
		
84

  
85 85
		indAssociation.setAssociatedSpecimenOrObservation(associatedSpecimen);
86 86
		LanguageString langString = LanguageString.NewInstance("Test", Language.ENGLISH());
87
		
87

  
88 88
		indAssociation.putDescription(langString);
89
		
89

  
90 90
		quantData = QuantitativeData.NewInstance();
91
		
91

  
92 92
		StatisticalMeasurementValue statisticalValue = StatisticalMeasurementValue.NewInstance();
93
		
93

  
94 94
		statisticalValue.setType(StatisticalMeasure.AVERAGE() );
95
		
95

  
96 96
		statisticalValue.setValue((float) 23.8);
97
		
97

  
98 98
		quantData.addStatisticalValue(statisticalValue);
99 99
		taxon = Taxon.NewInstance(BotanicalName.NewInstance(Rank.SPECIES(), "Abies", null, "alba", null, null, null, null, null), null);
100 100
		taxonInteraction = TaxonInteraction.NewInstance();
101 101
		taxonInteraction.setTaxon2(taxon);
102 102
		langString = LanguageString.NewInstance("TestTaxonInteraction", Language.ENGLISH());
103
		
103

  
104 104
		taxonInteraction.putDescription(langString);
105
		
105

  
106 106
	}
107 107

  
108 108
/* ************************** TESTS **********************************************************/
......
112 112
		assertEquals(clone.getStateData().size(),categorialData.getStateData().size() );
113 113
		assertSame(clone.getStateData().get(0), categorialData.getStateData().get(0));
114 114
		assertNotSame(clone, categorialData);
115
			
115

  
116 116
	}
117
	
117

  
118 118
	@Test
119 119
	public void testCloneIndividualAssociation(){
120 120
		IndividualsAssociation clone = (IndividualsAssociation) indAssociation.clone();
......
122 122
		assertNotSame(clone.getDescription().get(Language.ENGLISH()), indAssociation.getDescription().get(Language.ENGLISH()));
123 123
	}
124 124

  
125
	
125

  
126 126
	@Test
127 127
	public void testCloneQuantitativeData(){
128 128
		QuantitativeData clone = (QuantitativeData) quantData.clone();
129 129
		assertTrue(clone.getStatisticalValues().iterator().next().getValue() == quantData.getStatisticalValues().iterator().next().getValue());
130 130
		assertNotSame(clone.getStatisticalValues().iterator().next(), quantData.getStatisticalValues().iterator().next());
131
		
131

  
132 132
	}
133
	
133

  
134 134
	@Test
135 135
	public void testCloneTaxonInteraction(){
136 136
		TaxonInteraction clone = (TaxonInteraction)taxonInteraction.clone();
137 137
		assertNotSame(clone.getDescriptions().get(Language.ENGLISH()), taxonInteraction.getDescriptions().get(Language.ENGLISH()));
138 138
		assertTrue(clone.getDescription(Language.ENGLISH()).equals(taxonInteraction.getDescription(Language.ENGLISH())));
139 139
	}
140
	
140

  
141 141
	@Test
142 142
	public void testGetModifiersVocabulary(){
143 143
		TaxonDescription desc = TaxonDescription.NewInstance();
......
145 145
		desc.addElement(data);
146 146
		StateData stateData = StateData.NewInstance();
147 147
		data.addStateData(stateData);
148
		
148

  
149 149
		TermType modifierType = TermType.Modifier;
150 150
		TermVocabulary<DefinedTerm> plantPartVoc = TermVocabulary.NewInstance(modifierType,"plant parts", "plant parts", "parts", null);
151 151
		DefinedTerm leaf = DefinedTerm.NewModifierInstance("leaf", "leaf", null);
......
162 162
		ethnicGroupVoc.addTerm(scots);
163 163
		data.addModifier(scots);
164 164

  
165
		
165

  
166 166
		List<DefinedTerm> modifiers = data.getModifiers(plantPartVoc);
167 167
		Assert.assertEquals("There should be 2 modifiers of type 'plant part'", 2, modifiers.size());
168 168
		Assert.assertEquals("There should be 3 terms in the 'plant part' vocabulary", 3, plantPartVoc.size());
169 169
		Assert.assertEquals("There should be 1 modifiers of type 'ethnic group'", 1, data.getModifiers(ethnicGroupVoc).size());
170 170
		Assert.assertEquals("There should be 3 modifiers all together", 3, data.getModifiers().size());
171
		
171

  
172 172
	}
173
	
173

  
174 174
}
175 175

  
176 176

  

Also available in: Unified diff