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 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.getContent().getText().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
        assertTrue(LinkElement.testIfLinkElement(featureBlockDistribution.getOriginalSourcesSections().get(0).getLinksInElement().get(0), evans_et_al_referenceCitation, "cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
118

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

    
122
    }
123

    
124
    @Test
125
    public void testFeatureBiologyAndEcology() {
126

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

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

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

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

    
151
    @Test
152
    public void testFeatureConservation() {
153

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

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

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

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

    
176
    @Test
177
    public void testFeatureCommonName() {
178

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

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

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

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

    
200
    }
201

    
202
    @Test
203
    public void testFeatureUses() {
204

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

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

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

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

    
227
    @Test
228
    public void testFeatureDiscussion() {
229

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

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

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

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

    
254
    @Test
255
    public void testFeatureMaterialsExamined() {
256

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

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

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

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

    
281
}
(1-1/2)