Project

General

Profile

Download (12.7 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2009 EDIT
4
 * European Distributed Institute of Taxonomy
5
 * http://www.e-taxonomy.eu
6
 *
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 * See LICENSE.TXT at the top of this package for the full license terms.
9
 */
10
package eu.etaxonomy.dataportal.selenium.tests.palmae;
11

    
12
import static org.junit.Assert.*;
13

    
14
import java.net.MalformedURLException;
15
import java.util.List;
16
import java.util.UUID;
17

    
18
import org.apache.commons.lang.StringUtils;
19
import org.junit.After;
20
import org.junit.Before;
21
import org.junit.Ignore;
22
import org.junit.Test;
23
import org.openqa.selenium.By;
24
import org.openqa.selenium.WebElement;
25

    
26
import eu.etaxonomy.dataportal.DataPortalContext;
27
import eu.etaxonomy.dataportal.elements.BaseElement;
28
import eu.etaxonomy.dataportal.elements.DescriptionElementRepresentation;
29
import eu.etaxonomy.dataportal.elements.FeatureBlock;
30
import eu.etaxonomy.dataportal.elements.ImgElement;
31
import eu.etaxonomy.dataportal.elements.LinkElement;
32
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
33
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
34
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
35

    
36
/**
37
 * @author a.kohlbecker
38
 *
39
 */
40

    
41
@DataPortalContexts( { DataPortalContext.palmae })
42
public class Calamus_acanthospathus_TaxonProfileTest extends CdmDataPortalTestBase{
43

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

    
46
    TaxonProfilePage p = null;
47

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

    
51
        p = new TaxonProfilePage(driver, getContext(), taxonUuid);
52

    
53
    }
54

    
55

    
56
    @Test
57
    public void testTitleAndTabs() {
58

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

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

    
70
    }
71

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

    
79

    
80
    @Test
81
    @Ignore /* ignoring until the change of T. Evans et al. 2002 to T. Evans, K. Sengdala, B. Thammavong, O.V. Viengkham and J. Dransfield. 2002 is clarified */
82
    public void testFeatures() {
83
        assertEquals("Content", p.getTableOfContentHeader());
84
        List<LinkElement> links = p.getTableOfContentLinks();
85
        assertNotNull("Expecting a list of TOC links in the profile page.", links);
86

    
87
        FeatureBlock featureBlock;
88
        int featureId = 0;
89

    
90
        int descriptionElementFontSize = 11;
91
        String expectedCssDisplay = "inline";
92
        String expectedListStyleType = "none";
93
        String expectedListStylePosition = "outside";
94
        String expectedListStyleImage = "none";
95
        int indent = 23;
96

    
97
        /* distribution */
98
        String featureClass = "distribution";
99
        String featureLabel = "Distribution";
100
        String blockTextFull = featureLabel + "\n\n\nMap accurate to TDWG level 3 distributions\n\nAssam, China South-Central, China Southeast, East Himalaya, India, Laos, Myanmar, Nepal, Thailand, Tibet (World Checklist of Monocotyledons)\nIndia (North-east), Bhutan, Myanmar, China (Tibet, South-east and South Yunnan), Thailand (North) and Laos (North). (T. Evans et al. 2002)";
101

    
102
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
103
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "p", "span");
104

    
105
        assertEquals(blockTextFull, featureBlock.getText());
106
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
107
        assertEquals(2, featureBlock.getOriginalSourcesSections().size());
108
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "World Checklist of Monocotyledons", this.getContext().getBaseUri().toString()));
109
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(1).getLinksInElement().get(0), "T. Evans et al. 2002", this.getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
110

    
111
        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
112
        assertEquals("Map accurate to TDWG level 3 distributions", featureBlock.getElement().findElement(By.className("distribution_map_caption")).getText());
113

    
114

    
115
        /* Biology And Ecology */
116
        featureClass = "biology-and-ecology";
117
        featureLabel = "Biology And Ecology";
118
        blockTextFull = featureLabel + "\nEvergreen forest. In Laos at 1800 m, in Thailand at 1500 - 1700 m, in South Yunnan at 1600 m. (T. Evans et al. 2002)";
119
        expectedCssDisplay = "list-item";
120
        expectedListStyleType = "none";
121

    
122
        p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
123
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
124

    
125
        assertEquals(blockTextFull, featureBlock.getText());
126
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
127
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
128
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
129

    
130

    
131
        /* Conservation */
132
        featureClass = "conservation";
133
        featureLabel = "Conservation";
134
        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). (T. Evans et al. 2002)";
135
        expectedCssDisplay = "list-item";
136
        expectedListStyleType = "none";
137

    
138
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
139
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
140

    
141
        assertEquals(blockTextFull, featureBlock.getText());
142
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
143
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
144
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
145

    
146
        /* Common Name */
147
        featureClass = "common-name";
148
        featureLabel = "Common Name";
149
        blockTextFull = featureLabel + "\nwai hom (Lao Loum), blong eur (Khamu), wai hawm (Thailand) (T. Evans et al. 2002)";
150
        expectedCssDisplay = "list-item";
151
        expectedListStyleType = "none";
152

    
153
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
154
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
155

    
156
        assertEquals(blockTextFull, featureBlock.getText());
157
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
158
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
159
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
160

    
161
        /* Uses */
162
        featureClass = "uses";
163
        featureLabel = "Uses";
164
        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. (T. Evans et al. 2002)";
165
        expectedCssDisplay = "list-item";
166
        expectedListStyleType = "none";
167

    
168
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
169
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
170

    
171
        assertEquals(blockTextFull, featureBlock.getText());
172
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
173
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
174
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
175

    
176
        /* Discussion */
177
        featureClass = "discussion";
178
        featureLabel = "Discussion";
179
        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";
180
        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). (T. Evans et al. 2002)";
181
        expectedCssDisplay = "list-item";
182
        expectedListStyleType = "none";
183

    
184
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
185
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
186

    
187
        assertTrue(featureBlock.getText().startsWith(blockTextBegin));
188
        assertTrue(featureBlock.getText().endsWith(blockTextEnd));
189
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
190
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
191
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
192

    
193
        /* Discussion */
194
        featureClass = "materials-examined";
195
        featureLabel = "Materials Examined";
196
        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.)";
197
        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). (T. Evans et al. 2002)";
198
        expectedCssDisplay = "list-item";
199
        expectedListStyleType = "none";
200

    
201
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
202
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "ul", "li");
203

    
204
        assertTrue(featureBlock.getText().startsWith(blockTextBegin));
205
        assertTrue(featureBlock.getText().endsWith(blockTextEnd));
206
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
207
        assertEquals(1, featureBlock.getOriginalSourcesSections().size());
208
        assertTrue(LinkElement.testIfLinkElement(featureBlock.getOriginalSourcesSections().get(0).getLinksInElement().get(0), "T. Evans et al. 2002", getContext().getBaseUri().toString() + "?q=cdm_dataportal/reference/706c5e5e-1dac-4fb2-b849-8e99ad7d63aa"));
209

    
210
    }
211

    
212
}
    (1-1/1)