Project

General

Profile

Download (15.3 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.DataPortalContext;
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( { DataPortalContext.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 = "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";
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 blockTextFull = featureLabel + "\n\n\n\n\nMap 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(blockTextFull, featureBlockDistribution.getText());
111
        featureBlockDistribution.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
112
        assertEquals(1, featureBlockDistribution.getOriginalSourcesSections().size());
113
        // NOTE: the first source has been deleted in latest data
114
        // assertTrue(LinkElement.testIfLinkElement(featureBlockDistribution.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "World Checklist of Monocotyledons", getContext().getBaseUri().toString()));
115
        assertTrue(LinkElement.testIfLinkElement(featureBlockDistribution.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
116

    
117
        assertNotNull("Expecting an OpenLayers map", featureBlockDistribution.getElement().findElement(By.id("openlayers-map-distribution")));
118
        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());
119

    
120
    }
121

    
122
    @Test
123
    public void testFeatureBiologyAndEcology() {
124

    
125
        int featureId = 2;
126
        int descriptionElementFontSize = 11;
127
        String expectedCssDisplay = "inline";
128
        String expectedListStyleType = "none";
129
        String expectedListStylePosition = "outside";
130
        String expectedListStyleImage = "none";
131
        int indent = 23;
132

    
133
        /* Biology And Ecology */
134
        String featureClass = "biology-and-ecology";
135
        String featureLabel = "Biology And Ecology";
136
        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 + ")";
137
        expectedCssDisplay = "list-item";
138
        expectedListStyleType = "none";
139

    
140
        p.testTableOfContentEntry(featureId,featureLabel, featureClass);
141
        FeatureBlock featureBlockBioEco = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
142

    
143
        assertEquals(blockTextFull, featureBlockBioEco.getText());
144
        featureBlockBioEco.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
145
        assertEquals(1, featureBlockBioEco.getOriginalSourcesSections().size());
146
        assertTrue(LinkElement.testIfLinkElement(featureBlockBioEco.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
147
    }
148

    
149
    @Test
150
    public void testFeatureConservation() {
151

    
152
        int featureId = 3;
153
        int descriptionElementFontSize = 11;
154
        String expectedListStyleType = "none";
155
        String expectedCssDisplay = "list-item";
156
        String expectedListStylePosition = "outside";
157
        String expectedListStyleImage = "none";
158
        int indent = 23;
159

    
160
        /* Conservation */
161
        String featureClass = "conservation";
162
        String featureLabel = "Conservation";
163
        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 + ")";
164

    
165
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
166
        FeatureBlock featureBlockConservation = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
167

    
168
        assertEquals(blockTextFull, featureBlockConservation.getText());
169
        featureBlockConservation.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
170
        assertEquals(1, featureBlockConservation.getOriginalSourcesSections().size());
171
        assertTrue(LinkElement.testIfLinkElement(featureBlockConservation.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
172
    }
173

    
174
    @Test
175
    public void testFeatureCommonName() {
176

    
177
        int featureId = 4;
178
        String expectedCssDisplay = "list-item";
179
        String expectedListStyleType = "none";
180
        int descriptionElementFontSize = 11;
181
        String expectedListStylePosition = "outside";
182
        String expectedListStyleImage = "none";
183
        int indent = 23;
184

    
185
        /* Common Name */
186
        String featureClass = "common-name";
187
        String featureLabel = "Common Name";
188
        String blockTextFull = featureLabel + "\nwai hom (Lao Loum), blong eur (Khamu), wai hawm (Thailand) (" + evans_et_al_referenceCitation + ")";
189

    
190
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
191
        FeatureBlock featureBlockCommonName = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
192

    
193
        assertEquals(blockTextFull, featureBlockCommonName.getText());
194
        featureBlockCommonName.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
195
        assertEquals(1, featureBlockCommonName.getOriginalSourcesSections().size());
196
        assertTrue(LinkElement.testIfLinkElement(featureBlockCommonName.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
197

    
198
    }
199

    
200
    @Test
201
    public void testFeatureUses() {
202

    
203
        int featureId = 5;
204
        String expectedCssDisplay = "list-item";
205
        String expectedListStyleType = "none";
206
        int descriptionElementFontSize = 11;
207
        String expectedListStylePosition = "outside";
208
        String expectedListStyleImage = "none";
209
        int indent = 23;
210

    
211
        /* Uses */
212
        String featureClass = "uses";
213
        String featureLabel = "Uses";
214
        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 + ")";
215

    
216
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
217
        FeatureBlock featureBlockUses = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
218

    
219
        assertEquals(blockTextFull, featureBlockUses.getText());
220
        featureBlockUses.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
221
        assertEquals(1, featureBlockUses.getOriginalSourcesSections().size());
222
        assertTrue(LinkElement.testIfLinkElement(featureBlockUses.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
223
    }
224

    
225
    @Test
226
    public void testFeatureDiscussion() {
227

    
228
        int featureId = 1;
229
        String expectedCssDisplay = "list-item";
230
        String expectedListStyleType = "none";
231
        int descriptionElementFontSize = 11;
232
        String expectedListStylePosition = "outside";
233
        String expectedListStyleImage = "none";
234
        int indent = 23;
235

    
236
        /* Discussion */
237
        String featureClass = "discussion";
238
        String featureLabel = "Discussion";
239
        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";
240
        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 + ")";
241

    
242
        p.testTableOfContentEntry(featureId, featureLabel, featureClass);
243
        FeatureBlock featureBlockDiscussion = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
244

    
245
        assertTrue(featureBlockDiscussion.getText().startsWith(blockTextBegin));
246
        assertTrue(featureBlockDiscussion.getText().endsWith(blockTextEnd));
247
        featureBlockDiscussion.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
248
        assertEquals(1, featureBlockDiscussion.getOriginalSourcesSections().size());
249
        assertTrue(LinkElement.testIfLinkElement(featureBlockDiscussion.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
250
    }
251

    
252
    @Test
253
    public void testFeatureMaterialsExamined() {
254

    
255
        int featureId = 6;
256
        String expectedCssDisplay = "list-item";
257
        String expectedListStyleType = "none";
258
        int descriptionElementFontSize = 11;
259
        String expectedListStylePosition = "outside";
260
        String expectedListStyleImage = "none";
261
        int indent = 23;
262

    
263
        /* Materials Examined */
264
        String featureClass = "materials-examined";
265
        String featureLabel = "Materials Examined";
266
        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.)";
267
        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 + ")";
268

    
269
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
270
        FeatureBlock featureBlockMaterials = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
271

    
272
        assertTrue(featureBlockMaterials.getText().startsWith(blockTextBegin));
273
        assertTrue(featureBlockMaterials.getText().endsWith(blockTextEnd));
274
        featureBlockMaterials.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
275
        assertEquals(1, featureBlockMaterials.getOriginalSourcesSections().size());
276
        assertTrue(LinkElement.testIfLinkElement(featureBlockMaterials.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
277
    }
278

    
279
}
(1-1/2)