Project

General

Profile

Download (16.1 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2009 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.dataportal.selenium.tests.palmae;
10

    
11
import java.net.MalformedURLException;
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import org.junit.Before;
16
import org.junit.Test;
17
import org.openqa.selenium.By;
18

    
19
import eu.etaxonomy.dataportal.DataPortalSite;
20
import eu.etaxonomy.dataportal.elements.FeatureBlock;
21
import eu.etaxonomy.dataportal.elements.ImgElement;
22
import eu.etaxonomy.dataportal.elements.LinkElement;
23
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
24
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
25
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
26

    
27
/**
28
 * @author a.kohlbecker
29
 *
30
 */
31

    
32
@DataPortalContexts( { DataPortalSite.palmae })
33
public class Calamus_acanthospathus_TaxonProfileTest extends CdmDataPortalTestBase{
34

    
35
    static UUID taxonUuid = UUID.fromString("bb340c78-880e-4dd0-91ff-81788a482b31");
36

    
37
    static TaxonProfilePage p = null;
38

    
39
    /**
40
     * NOTE
41
     *
42
     * This was formerly formated as '" + evans_et_al_referenceCitation + "' by special citation
43
     * string generation in the drupal code which need to be removed
44
     * in order to retain the maintainability of the code.
45
     */
46
    String evans_et_al_referenceCitation = "Evans, T., Sengdala, K., Thammavong, B., Viengkham, O.V. & Dransfield, J. 2002: A Synopsis of the Rattans (Arecaceae: Calamoideae) of Laos and Neighbouring Parts of Indochina";
47

    
48
    @Before
49
    public void setUp() throws MalformedURLException {
50

    
51
        if(p == null){
52
            p = new TaxonProfilePage(driver, getContext(), taxonUuid);
53
        }
54

    
55
    }
56

    
57

    
58
    @Test
59
    public void testTitleAndTabs() {
60

    
61
        assertEquals(getContext().prepareTitle("Calamus acanthospathus Griff., Calcutta J. Nat. Hist. 5: 39. 1845"), driver.getTitle());
62
        assertNull("Authorship information should be hidden", p.getAuthorInformationText());
63

    
64
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
65
        int tabId = 0;
66
        assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
67
        assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
68
        assertEquals("Images", primaryTabs.get(tabId++).getText());
69
//        assertEquals("Specimens", primaryTabs.get(tabId++).getText()); is disabled by layout settings
70
        assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
71

    
72
    }
73

    
74
    @Test
75
    public void testProfileImage() {
76
        ImgElement profileImage = p.getProfileImage();
77
        assertNotNull("Expecting profile images to be switched on", profileImage);
78
        assertTrue("Expecting image palm_tc_29336_1.jpg", profileImage.getSrcUrl().toString().endsWith("/palm_tc_29336_1.jpg"));
79
    }
80

    
81

    
82
    @Test
83
    public void testFeatureToc() {
84

    
85
        assertEquals("Content", p.getTableOfContentHeader());
86
        List<LinkElement> links = p.getTableOfContentLinks();
87
        assertNotNull("Expecting a list of TOC links in the profile page.", links);
88
    }
89

    
90
    @Test
91
    public void testFeatureDistribution() {
92

    
93
        int featureId = 0;
94

    
95
        int descriptionElementFontSize = 11;
96
        String expectedListStyleType = "none";
97
        String expectedCssDisplay = "inline";
98
        String expectedListStylePosition = "outside";
99
        String expectedListStyleImage = "none";
100
        int indent = 23;
101

    
102
        /* distribution */
103
        String featureClass = "distribution";
104
        String featureLabel = "Distribution";
105
        String contentTextFull = "Map uses TDWG level 3 distributions (http://www.nhm.ac.uk/hosted_sites/tdwg/geogrphy.html)\nAssam (World Checklist of Arecaceae), China South-Central (World Checklist of Arecaceae), China Southeast (World Checklist of Arecaceae), East Himalaya (World Checklist of Arecaceae), India (World Checklist of Arecaceae), Laos (World Checklist of Arecaceae), Myanmar (World Checklist of Arecaceae), Nepal (World Checklist of Arecaceae), Thailand (World Checklist of Arecaceae), Tibet (World Checklist of Arecaceae)\nIndia (North-east), Bhutan, Myanmar, China (Tibet, South-east and South Yunnan), Thailand (North) and Laos (North). (T. Evans & K. Sengdala & B. Thammavong & O.V. Viengkham & J. Dransfield, A Synopsis of the Rattans (Arecaceae: Calamoideae) of Laos and Neighbouring Parts of Indochina. 2002)";
106

    
107
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
108
        FeatureBlock featureBlockDistribution = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
109

    
110
        assertEquals(featureLabel, featureBlockDistribution.getTitle().getText());
111
        assertEquals(contentTextFull, featureBlockDistribution.getContentText().trim());
112

    
113
        featureBlockDistribution.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
114
        assertEquals(1, featureBlockDistribution.getOriginalSourcesSections().size());
115
        // NOTE: the first source has been deleted in latest data
116
        // assertTrue(LinkElement.testIfLinkElement(featureBlockDistribution.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "World Checklist of Monocotyledons", getContext().getBaseUri().toString()));
117
        assertEquals(evans_et_al_referenceCitation, featureBlockDistribution.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
118
        assertTrue(LinkElement.testIfLinkElement(featureBlockDistribution.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
119

    
120
        assertNotNull("Expecting an OpenLayers map", featureBlockDistribution.getElement().findElement(By.id("openlayers-map-distribution")));
121
        assertEquals("Map uses TDWG level 3 distributions (http://www.nhm.ac.uk/hosted_sites/tdwg/geogrphy.html)", featureBlockDistribution.getElement().findElement(By.className("distribution_map_caption")).getText());
122

    
123
    }
124

    
125
    @Test
126
    public void testFeatureBiologyAndEcology() {
127

    
128
        int featureId = 2;
129
        int descriptionElementFontSize = 11;
130
        String expectedCssDisplay = "inline";
131
        String expectedListStyleType = "none";
132
        String expectedListStylePosition = "outside";
133
        String expectedListStyleImage = "none";
134
        int indent = 23;
135

    
136
        /* Biology And Ecology */
137
        String featureClass = "biology-and-ecology";
138
        String featureLabel = "Biology And Ecology";
139
        String blockTextFull = featureLabel + "\nEvergreen forest. In Laos at 1800 m, in Thailand at 1500 - 1700 m, in South Yunnan at 1600 m. (" + evans_et_al_referenceCitation + ")";
140
        expectedCssDisplay = "list-item";
141
        expectedListStyleType = "none";
142

    
143
        p.testTableOfContentEntry(featureId,featureLabel, featureClass);
144
        FeatureBlock featureBlockBioEco = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
145

    
146
        assertEquals(blockTextFull, featureBlockBioEco.getText());
147
        featureBlockBioEco.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
148
        assertEquals(1, featureBlockBioEco.getOriginalSourcesSections().size());
149
        assertEquals(evans_et_al_referenceCitation, featureBlockBioEco.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
150
        assertTrue(LinkElement.testIfLinkElement(featureBlockBioEco.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
151
    }
152

    
153
    @Test
154
    public void testFeatureConservation() {
155

    
156
        int featureId = 3;
157
        int descriptionElementFontSize = 11;
158
        String expectedListStyleType = "none";
159
        String expectedCssDisplay = "list-item";
160
        String expectedListStylePosition = "outside";
161
        String expectedListStyleImage = "none";
162
        int indent = 23;
163

    
164
        /* Conservation */
165
        String featureClass = "conservation";
166
        String featureLabel = "Conservation";
167
        String blockTextFull = featureLabel + "\nOf moderate concern. In Indochina it apparently produces at most one or two additional stems and so probably regenerates poorly after harvesting, putting it at elevated risk even though it is widespread and occurs in high altitude forests, which are less threatened by agriculture and logging. It had declined severely due to harvesting in Sikkim over 100 years ago (Anderson 1869). (" + evans_et_al_referenceCitation + ")";
168

    
169
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
170
        FeatureBlock featureBlockConservation = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
171

    
172
        assertEquals(blockTextFull, featureBlockConservation.getText());
173
        featureBlockConservation.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
174
        assertEquals(1, featureBlockConservation.getOriginalSourcesSections().size());
175
        assertEquals(evans_et_al_referenceCitation, featureBlockConservation.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
176
        assertTrue(LinkElement.testIfLinkElement(featureBlockConservation.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
177
    }
178

    
179
    @Test
180
    public void testFeatureCommonName() {
181

    
182
        int featureId = 4;
183
        String expectedCssDisplay = "list-item";
184
        String expectedListStyleType = "none";
185
        int descriptionElementFontSize = 11;
186
        String expectedListStylePosition = "outside";
187
        String expectedListStyleImage = "none";
188
        int indent = 23;
189

    
190
        /* Common Name */
191
        String featureClass = "common-name";
192
        String featureLabel = "Common Name";
193
        String blockTextFull = featureLabel + "\nwai hom (Lao Loum), blong eur (Khamu), wai hawm (Thailand) (" + evans_et_al_referenceCitation + ")";
194

    
195
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
196
        FeatureBlock featureBlockCommonName = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
197

    
198
        assertEquals(blockTextFull, featureBlockCommonName.getText());
199
        featureBlockCommonName.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
200
        assertEquals(1, featureBlockCommonName.getOriginalSourcesSections().size());
201
        assertEquals(evans_et_al_referenceCitation, featureBlockCommonName.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
202
        assertTrue(LinkElement.testIfLinkElement(featureBlockCommonName.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
203

    
204
    }
205

    
206
    @Test
207
    public void testFeatureUses() {
208

    
209
        int featureId = 5;
210
        String expectedCssDisplay = "list-item";
211
        String expectedListStyleType = "none";
212
        int descriptionElementFontSize = 11;
213
        String expectedListStylePosition = "outside";
214
        String expectedListStyleImage = "none";
215
        int indent = 23;
216

    
217
        /* Uses */
218
        String featureClass = "uses";
219
        String featureLabel = "Uses";
220
        String  blockTextFull = featureLabel + "\nThis species is highly valued for its excellent quality small-diameter cane throughout its range. There are small trial plantations in South Yunnan. (" + evans_et_al_referenceCitation + ")";
221

    
222
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
223
        FeatureBlock featureBlockUses = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
224

    
225
        assertEquals(blockTextFull, featureBlockUses.getText());
226
        featureBlockUses.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
227
        assertEquals(1, featureBlockUses.getOriginalSourcesSections().size());
228
        assertEquals(evans_et_al_referenceCitation, featureBlockUses.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
229
        assertTrue(LinkElement.testIfLinkElement(featureBlockUses.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
230
    }
231

    
232
    @Test
233
    public void testFeatureDiscussion() {
234

    
235
        int featureId = 1;
236
        String expectedCssDisplay = "list-item";
237
        String expectedListStyleType = "none";
238
        int descriptionElementFontSize = 11;
239
        String expectedListStylePosition = "outside";
240
        String expectedListStyleImage = "none";
241
        int indent = 23;
242

    
243
        /* Discussion */
244
        String featureClass = "discussion";
245
        String featureLabel = "Discussion";
246
        String blockTextBegin = featureLabel + "\nBeccari (1908) confidently synonymised C. montanus under C. acanthospathus on the basis of the protologue and some detached fruits at K. They match well but";
247
        String blockTextEnd = "represent arbitrary divisions in a continuum between more and less robust individuals. There is no doubt about their identity with C. acanthospathus, a conclusion also reached by Wei (1986). (" + evans_et_al_referenceCitation + ")";
248

    
249
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
250
        FeatureBlock featureBlockDiscussion = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
251

    
252
        assertTrue(featureBlockDiscussion.getText().startsWith(blockTextBegin));
253
        assertTrue(featureBlockDiscussion.getText().endsWith(blockTextEnd));
254
        featureBlockDiscussion.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
255
        assertEquals(1, featureBlockDiscussion.getOriginalSourcesSections().size());
256
        assertEquals(evans_et_al_referenceCitation, featureBlockDiscussion.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
257
        assertTrue(LinkElement.testIfLinkElement(featureBlockDiscussion.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
258
    }
259

    
260
    @Test
261
    public void testFeatureMaterialsExamined() {
262

    
263
        int featureId = 6;
264
        String expectedCssDisplay = "list-item";
265
        String expectedListStyleType = "none";
266
        int descriptionElementFontSize = 11;
267
        String expectedListStylePosition = "outside";
268
        String expectedListStyleImage = "none";
269
        int indent = 23;
270

    
271
        /* Materials Examined */
272
        String featureClass = "materials-examined";
273
        String featureLabel = "Materials Examined";
274
        String blockTextBegin = featureLabel + "\nINDIA (NORTH-EAST): Sikkim, undated, (fr.), Hooker s.n. E72 (K); Khasia, undated, (pist.), Griffith 503 (K). BHUTAN: Sarbhang Distr., 2.5 km below Getchu on Chirang Road, 12 March 1982, (ster.)";
275
        String blockTextEnd = "A. 5293 (K, BM, BK). LAOS (NORTH): Huaphanh Province, Viengthong Distr., Ban Sakok, Phou Loeuy Noy, 21 June 1999, (fr.), Oulathong OL 231 (FRCL, K). (" + evans_et_al_referenceCitation + ")";
276

    
277
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
278
        FeatureBlock featureBlockMaterials = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
279

    
280
        assertTrue(featureBlockMaterials.getText().startsWith(blockTextBegin));
281
        assertTrue(featureBlockMaterials.getText().endsWith(blockTextEnd));
282
        featureBlockMaterials.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
283
        assertEquals(1, featureBlockMaterials.getOriginalSourcesSections().size());
284
        assertEquals(evans_et_al_referenceCitation, featureBlockMaterials.getOriginalSourcesSections().get(0).getElement().findElement(By.className("reference")).getText());
285
    }
286

    
287
}
(1-1/2)