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.cichorieae;
|
11
|
|
12
|
import static org.junit.Assert.assertEquals;
|
13
|
import static org.junit.Assert.assertNotNull;
|
14
|
import static org.junit.Assert.assertNull;
|
15
|
import static org.junit.Assert.assertTrue;
|
16
|
|
17
|
import java.net.MalformedURLException;
|
18
|
import java.util.List;
|
19
|
import java.util.UUID;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.junit.Before;
|
23
|
import org.junit.Test;
|
24
|
import org.openqa.selenium.By;
|
25
|
import org.openqa.selenium.NoSuchElementException;
|
26
|
import org.openqa.selenium.WebElement;
|
27
|
|
28
|
import eu.etaxonomy.dataportal.DataPortalContext;
|
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.elements.MultipartDescriptionElementRepresentation;
|
33
|
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
|
34
|
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
|
35
|
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
|
36
|
|
37
|
/**
|
38
|
* @author a.kohlbecker
|
39
|
*
|
40
|
*/
|
41
|
|
42
|
@DataPortalContexts( { DataPortalContext.cichorieae })
|
43
|
public class Lactuca_triquetra_TaxonProfileTest extends CdmDataPortalTestBase{
|
44
|
|
45
|
public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
|
46
|
|
47
|
static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
|
48
|
|
49
|
TaxonProfilePage p = null;
|
50
|
|
51
|
@Before
|
52
|
public void setUp() throws MalformedURLException {
|
53
|
|
54
|
if(p != null && driver != null ){
|
55
|
logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
|
56
|
}
|
57
|
p = new TaxonProfilePage(driver, getContext(), taxonUuid);
|
58
|
|
59
|
}
|
60
|
|
61
|
|
62
|
@Test
|
63
|
public void testTitleAndTabs() {
|
64
|
|
65
|
assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
|
66
|
assertNull("Authorship information should be hidden", p.getAuthorInformationText());
|
67
|
|
68
|
List<LinkElement> primaryTabs = p.getPrimaryTabs();
|
69
|
int tabId = 0;
|
70
|
assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
|
71
|
assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
|
72
|
assertEquals("Images", primaryTabs.get(tabId++).getText());
|
73
|
assertEquals("Specimens", primaryTabs.get(tabId++).getText());
|
74
|
assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
|
75
|
|
76
|
}
|
77
|
|
78
|
@Test
|
79
|
public void testProfileImage() {
|
80
|
ImgElement profileImage = p.getProfileImage();
|
81
|
assertNotNull("Expecting profile images to be switched on", profileImage);
|
82
|
assertTrue("Expecting image Lactuca_triquetra_Bc_01.jpg but was " + profileImage.getSrcUrl().toString(), profileImage.getSrcUrl().toString().matches("(?i).*Lactuca_triquetra_Bc_01\\.jpg.*"));
|
83
|
}
|
84
|
|
85
|
|
86
|
@Test
|
87
|
public void testFeatures() {
|
88
|
assertEquals("Content", p.getTableOfContentHeader());
|
89
|
List<LinkElement> links = p.getTableOfContentLinks();
|
90
|
assertNotNull("Expecting a list of TOC links in the profile page.", links);
|
91
|
|
92
|
FeatureBlock featureBlock;
|
93
|
int featureId = 0;
|
94
|
|
95
|
int descriptionElementFontSize = 12;
|
96
|
String expectedCssDisplay = "inline";
|
97
|
String expectedListStyleType = "none";
|
98
|
String expectedListStylePosition = "outside";
|
99
|
String expectedListStyleImage = "none";
|
100
|
int indent = 0;
|
101
|
|
102
|
/* Description */
|
103
|
String featureClass = "description";
|
104
|
String featureLabel = "Description";
|
105
|
String blockTextFull = null;
|
106
|
String blockTextBegin = featureLabel + "\nHerb, perennial, scoparious, 40-80 cm high. Flowering stems erect, triangular, medullary, glaucous-green, soon leafless, strongly branched; branches erect, slender. Cauline leaves few, glabrous.";
|
107
|
String blockTextEnd = "Pappus white, 6.0-7.0 mm long, persistent, fragile, shortly barbellate or scabridulous.\n\nbased on: Meikle, R.D. 1985: Flora auf Cyprus 2. - Kew (as Prenanthes triquetra).";
|
108
|
expectedListStyleType = "none";
|
109
|
|
110
|
p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
|
111
|
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
112
|
|
113
|
assertTrue(featureBlock.getText().startsWith(blockTextBegin));
|
114
|
assertTrue(featureBlock.getText().endsWith(blockTextEnd));
|
115
|
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
116
|
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
117
|
|
118
|
/* Distribution */
|
119
|
expectedCssDisplay = "block";
|
120
|
featureClass = "distribution";
|
121
|
featureLabel = "Distribution";
|
122
|
// below some assertions have been adapted to a bug in the library: TODO remove below comments when ticket is reviewed
|
123
|
// see #3475 (DescriptionServiceImpl.getOrderedDistributions loses distributions)
|
124
|
//
|
125
|
// original expectation disabled as bug occured:
|
126
|
// blockTextFull = featureLabel + "\nAsia-Temperate:\nCyprus 1,2; Lebanon-Syria (Lebanon 3,4,5); Palestine (Israel 5,6).\n1. Meikle, R. D., Flora of Cyprus 2. 1985, 2. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, 3. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984, 4. Boissier, E., Flora Orientalis 3. 1875, 5. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 1933, 6. Zohary, M. & Feinbrun-Dothan, N., Flora Palaestina 3. 1978)";
|
127
|
// interim expectation as long bug was not fixed:
|
128
|
// blockTextFull = featureLabel + "\n\n\nAsia-Temperate:\nCyprus 1,2; Lebanon-Syria (Lebanon 3,4,5); Palestine (Israel 6).\n1. Meikle, R. D., Flora of Cyprus 2. 1985, 2. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, 3. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984, 4. Boissier, E., Flora Orientalis 3. 1875, 5. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 1933, 6. Zohary, M. & Feinbrun-Dothan, N., Flora Palaestina 3. 1978";
|
129
|
// after fixig the bug #3475, more sources are now displayed than ever before:
|
130
|
blockTextFull = featureLabel + "\n\nAsia-Temperate:\nCyprus 1,2; Lebanon-Syria (Lebanon 3,4,5); Palestine (Israel 5,6,7).\n1. Meikle, R. D., Flora of Cyprus 2. 1985, 2. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, 3. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984, 4. Boissier, E., Flora Orientalis 3. 1875, 5. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 1933, 7. Zohary, M. & Feinbrun-Dothan, N., Flora Palaestina 3. 19786. (N)";
|
131
|
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
132
|
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
|
133
|
|
134
|
// TODO after #4166 (Map legend causes inconsistent spacing below map) is fixed the below trick which relaxes this test can be removed
|
135
|
String relaxedBlockText = featureBlock.getText().replaceFirst("\n\n\n", "\n\n");
|
136
|
assertEquals(blockTextFull, relaxedBlockText);
|
137
|
|
138
|
MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
|
139
|
logger.info(descriptionElement.getText());
|
140
|
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
141
|
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
142
|
// assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size()); //original version
|
143
|
// assertEquals("Expecting 6 FootnoteKeys", 6, featureBlock.getFootNoteKeys().size()); //version after bug #3475
|
144
|
assertEquals("Expecting 8 FootnoteKeys", 8, featureBlock.getFootNoteKeys().size()); // new version #3475 fixed
|
145
|
assertEquals("Expecting 7 Footnotes", 7, featureBlock.getFootNotes().size());
|
146
|
|
147
|
assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
|
148
|
WebElement mapCaptionElement = null;
|
149
|
try {
|
150
|
mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
|
151
|
} catch (NoSuchElementException e){
|
152
|
/* IGNORE */
|
153
|
}
|
154
|
assertNull(mapCaptionElement);
|
155
|
|
156
|
/* Uses */
|
157
|
featureClass = "ecology";
|
158
|
featureLabel = "Ecology";
|
159
|
blockTextFull = featureLabel + "\n500 m. On chalky cliffs or in flushes on serpentine.\n\nfrom: Meikle, R. D. 1985: Flora of Cyprus 2. – Kew. (as Prenanthes triquetra)";
|
160
|
expectedCssDisplay = "inline";
|
161
|
|
162
|
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
163
|
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
164
|
|
165
|
assertEquals(blockTextFull, featureBlock.getText());
|
166
|
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
167
|
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
168
|
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
169
|
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
170
|
|
171
|
|
172
|
/* Common names */
|
173
|
featureClass = "common-names";
|
174
|
featureLabel = "Common names";
|
175
|
expectedCssDisplay = "block";
|
176
|
// after bug #3475 was fixed the number of footnotes increased by one
|
177
|
blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان8,9\n8. recommended, 9. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000 (as Scariola triquetra (Labill.) Soják)";
|
178
|
|
179
|
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
180
|
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
|
181
|
|
182
|
assertEquals(blockTextFull, featureBlock.getText());
|
183
|
|
184
|
|
185
|
/* Uses */
|
186
|
featureClass = "credits";
|
187
|
featureLabel = "Credits";
|
188
|
blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
|
189
|
expectedCssDisplay = "block";
|
190
|
|
191
|
p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
|
192
|
featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
|
193
|
|
194
|
assertEquals(blockTextFull, featureBlock.getText());
|
195
|
featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
|
196
|
assertEquals(0, featureBlock.getOriginalSourcesSections().size());
|
197
|
assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
|
198
|
assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
|
199
|
|
200
|
}
|
201
|
|
202
|
}
|