Project

General

Profile

Download (11.6 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.Test;
22
import org.openqa.selenium.By;
23
import org.openqa.selenium.WebElement;
24

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

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

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

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

    
45
	TaxonProfilePage p = null;
46

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

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

    
52
	}
53

    
54

    
55
	@Test
56
	public void testTitleAndTabs() {
57

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

    
61
		List<LinkElement> primaryTabs = p.getPrimaryTabs();
62
		int tabId = 0;
63
		assertEquals("General", primaryTabs.get(tabId++).getText());
64
		assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
65
		assertEquals("Images", primaryTabs.get(tabId++).getText());
66
		assertEquals("Specimens", primaryTabs.get(tabId++).getText());
67
		assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
68

    
69
	}
70

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

    
78

    
79
	@Test
80
	public void testFeatures() {
81
		assertEquals("Content", p.getTableOfContentHeader());
82
		List<LinkElement> links = p.getTableOfContentLinks();
83
		assertNotNull("Expecting a list of TOC links in the profile page.", links);
84

    
85
		FeatureBlock featureBlock;
86
		int featureId = 0;
87

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

    
95
		/* distribution */
96
		String featureClass = "distribution";
97
		String featureLabel = "Distribution";
98
		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)";
99

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

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

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

    
112

    
113
		/* Biology And Ecology */
114
		featureClass = "biology_and_ecology";
115
		featureLabel = "Biology And Ecology";
116
		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)";
117
		expectedCssDisplay = "list-item";
118
		expectedListStyleType = "none";
119

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

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

    
128

    
129
		/* Conservation */
130
		featureClass = "conservation";
131
		featureLabel = "Conservation";
132
		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)";
133
		expectedCssDisplay = "list-item";
134
		expectedListStyleType = "none";
135

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

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

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

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

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

    
159
		/* Uses */
160
		featureClass = "uses";
161
		featureLabel = "Uses";
162
		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)";
163
		expectedCssDisplay = "list-item";
164
		expectedListStyleType = "none";
165

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

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

    
174
		/* Discussion */
175
		featureClass = "discussion";
176
		featureLabel = "Discussion";
177
		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";
178
		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)";
179
		expectedCssDisplay = "list-item";
180
		expectedListStyleType = "none";
181

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

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

    
191
		/* Discussion */
192
		featureClass = "materials_examined";
193
		featureLabel = "Materials Examined";
194
		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.)";
195
		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)";
196
		expectedCssDisplay = "list-item";
197
		expectedListStyleType = "none";
198

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

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

    
208
	}
209

    
210
}
    (1-1/1)