Project

General

Profile

Download (12 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.cichorieae;
10

    
11
import java.net.MalformedURLException;
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import org.apache.log4j.Logger;
16
import org.junit.Before;
17
import org.junit.Test;
18
import org.openqa.selenium.By;
19
import org.openqa.selenium.NoSuchElementException;
20
import org.openqa.selenium.WebElement;
21

    
22
import eu.etaxonomy.dataportal.DataPortalSite;
23
import eu.etaxonomy.dataportal.elements.FeatureBlock;
24
import eu.etaxonomy.dataportal.elements.ImgElement;
25
import eu.etaxonomy.dataportal.elements.LinkElement;
26
import eu.etaxonomy.dataportal.elements.MultipartDescriptionElementRepresentation;
27
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
28
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
29
import eu.etaxonomy.dataportal.pages.TaxonProfilePage;
30

    
31
/**
32
 * @author a.kohlbecker
33
 *
34
 */
35

    
36
@DataPortalContexts( { DataPortalSite.cichorieae })
37
public class Lactuca_triquetra_TaxonProfileTest extends CdmDataPortalTestBase{
38

    
39
    public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
40

    
41
    static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
42

    
43
    TaxonProfilePage p = null;
44

    
45
    @Before
46
    public void setUp() throws MalformedURLException {
47

    
48
        if(p != null && driver != null ){
49
            logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
50
        }
51
        p = new TaxonProfilePage(driver, getContext(), taxonUuid);
52

    
53
    }
54

    
55

    
56
    @Test
57
    public void testTitleAndTabs() {
58

    
59
        assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
60
        assertNull("Authorship information should be hidden", p.getAuthorInformationText());
61

    
62
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
63
        int tabId = 0;
64
        if(p.isZenTheme()) {
65
            assertEquals("General\n(active tab)", primaryTabs.get(tabId++).getText());
66
        } else {
67
            // old garland theme
68
            assertEquals("General", primaryTabs.get(tabId++).getText());
69
        }
70
        assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
71
        assertEquals("Images", primaryTabs.get(tabId++).getText());
72
        assertEquals("Specimens", primaryTabs.get(tabId++).getText());
73
        assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
74

    
75
    }
76

    
77
    @Test
78
    public void testProfileImage() {
79
        ImgElement profileImage = p.getProfileImage();
80
        assertNotNull("Expecting profile images to be switched on", profileImage);
81
        assertTrue("Expecting image Lactuca_triquetra_Bc_01.jpg but was " + profileImage.getSrcUrl().toString(), profileImage.getSrcUrl().toString().matches("(?i).*Lactuca_triquetra_Bc_01\\.jpg.*"));
82
    }
83

    
84

    
85
    @Test
86
    public void testFeatures() {
87
        assertEquals("Content", p.getTableOfContentHeader());
88
        List<LinkElement> links = p.getTableOfContentLinks();
89
        assertNotNull("Expecting a list of TOC links in the profile page.", links);
90

    
91
        FeatureBlock featureBlock;
92
        int featureId = 0;
93

    
94
        int descriptionElementFontSize = p.isZenTheme() ? 14 : 12;
95
        String expectedCssDisplay = "inline";
96
        String expectedListStyleType = "none";
97
        String expectedListStylePosition = "outside";
98
        String expectedListStyleImage = "none";
99
        int indent = 0;
100

    
101
        /* Description */
102
        String featureClass = "description";
103
        String featureLabel = "Description";
104
        String blockTextFull = null;
105
        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.";
106
        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).";
107
        expectedListStyleType = "none";
108

    
109
        p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
110
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
111

    
112
        assertTrue(featureBlock.getText().startsWith(blockTextBegin));
113
        assertTrue(featureBlock.getText().endsWith(blockTextEnd));
114
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
115
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
116

    
117
        /* Distribution */
118
        expectedCssDisplay = "block";
119
        featureClass = "distribution";
120
        featureLabel = "Distribution";
121
        // below some assertions have been adapted to a bug in the library: TODO remove below comments when ticket is reviewed
122
        //       see  #3475 (DescriptionServiceImpl.getOrderedDistributions loses distributions)
123
        //
124
        // original expectation disabled as bug occured:
125
//        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)";
126
        // interim expectation as long bug was not fixed:
127
//        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";
128
        // after fixig the bug #3475, more sources are now displayed than ever before:
129
        // after layout changes there is an additional space: 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)";
130
        blockTextFull = featureLabel + "\n\nAsia-Temperate:\nCyprus A,B; Lebanon-Syria (Lebanon C,D,E); Palestine (Israel E,1,F).\n"
131
                + "A. Meikle, R. D., Flora of Cyprus 2. 1985 (as Prenanthes triquetra), B. Osorio-Tafall, B. H. & Serafim, G. M., List of the vascular plants of Cyprus. 1973, C. Mouterde, P., Nouvelle flore du Liban et de la Syrie. Texte 3. 1978-1984 (as Scariola triquetra), D. Boissier, E., Flora Orientalis 3. 1875, E. Post, G. E. , Flora of Syria, Palestine, and Sinai 2. 1933, F. Zohary, M. & Feinbrun-Dothan, N., Flora Palaestina 3. 1978\n1. (N)";
132
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
133
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
134

    
135
        // TODO  after #4166 (Map legend causes inconsistent spacing below map) is fixed the below trick which relaxes this test can be removed
136
        String relaxedBlockText = featureBlock.getText().replaceFirst("\n\n\n", "\n\n");
137

    
138
        // FIXME ignore until #4411 is decided
139
        boolean is4411_OK = false;
140
        if(is4411_OK ) {
141
            assertEquals(blockTextFull, relaxedBlockText);
142

    
143
            MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElement(0);
144
            logger.info(descriptionElement.getText());
145
            featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
146
            assertEquals(0, featureBlock.getOriginalSourcesSections().size());
147
    //        assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size()); //original version
148
    //        assertEquals("Expecting 6 FootnoteKeys", 6, featureBlock.getFootNoteKeys().size());   //version after bug #3475
149
            assertEquals("Expecting 8 FootnoteKeys", 8, featureBlock.countFootNoteKeys()); // new version #3475 fixed
150
            assertEquals("Expecting 7 Footnotes", 7, featureBlock.countFootNotes());
151
        }
152

    
153
        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers-map-distribution")));
154
        WebElement mapCaptionElement = null;
155
        try {
156
            mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
157
        } catch (NoSuchElementException e){
158
            /* IGNORE */
159
        }
160
        assertNull(mapCaptionElement);
161

    
162
        /* Uses */
163
        featureClass = "ecology";
164
        featureLabel = "Ecology";
165
        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)";
166
        expectedCssDisplay = "inline";
167

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

    
171
        assertEquals(blockTextFull, featureBlock.getText());
172
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
173
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
174
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.countFootNoteKeys());
175
        assertEquals("Expecting no Footnotes", 0, featureBlock.countFootNotes());
176

    
177

    
178
        /* Common names */
179
        featureClass = "common-names";
180
        featureLabel = "Common names";
181
        expectedCssDisplay = "block";
182
        // after bug #3475 was fixed the number of footnotes increased by one
183
        blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكانG,2\nG. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000 (as Scariola triquetra (Labill.) Soják)\n2. recommended";
184

    
185
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
186
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
187

    
188
        assertEquals(blockTextFull, featureBlock.getText());
189

    
190

    
191
        /* Credits */
192
        featureClass = "credits";
193
        featureLabel = "Credits";
194
        blockTextFull = featureLabel + " Christodoulou C. S. 2009: Images (1 added). Makris C. 2009: Images (1 added).";
195
        if(p.isZenTheme()) {
196
            expectedCssDisplay = "inline";
197
        } else {
198
            // old garland theme
199
            expectedCssDisplay = "block";
200
        }
201

    
202
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
203
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
204

    
205
        assertEquals(blockTextFull, featureBlock.getText().replaceAll("\\n", " "));
206
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
207
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
208
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.countFootNoteKeys());
209
        assertEquals("Expecting no Footnotes", 0, featureBlock.countFootNotes());
210

    
211
    }
212

    
213
}
(12-12/13)