Project

General

Profile

Download (10.2 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.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_Bf_09.jpg but was " + profileImage.getSrcUrl().toString(), profileImage.getSrcUrl().toString().matches(".*Lactuca_triquetra_Bf_09\\.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
        // FIXME below some assertions have been adapted to a bug in the library, once this bug is fixed the
123
        //       disabled lines must be reenabled !!!
124
        //       see  #3475 (DescriptionServiceImpl.getOrderedDistributions loses distributions)
125
        //
126
        // FIXME re enable the line below
127
//        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)";
128
        // FIXME remove the line below
129
        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";
130
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
131
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
132

    
133
        assertEquals(blockTextFull, featureBlock.getText());
134

    
135
        MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
136
        logger.info(descriptionElement.getText());
137
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
138
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
139
//        assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size()); //FIXME enable this line
140
        assertEquals("Expecting 6 FootnoteKeys", 6, featureBlock.getFootNoteKeys().size());   //FIXME remove this line
141
        assertEquals("Expecting 6 Footnotes", 6, featureBlock.getFootNotes().size());
142

    
143
        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
144
        WebElement mapCaptionElement = null;
145
        try {
146
            mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
147
        } catch (NoSuchElementException e){
148
            /* IGNORE */
149
        }
150
        assertNull(mapCaptionElement);
151

    
152
        /* Uses */
153
        featureClass = "ecology";
154
        featureLabel = "Ecology";
155
        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)";
156
        expectedCssDisplay = "inline";
157

    
158
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
159
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
160

    
161
        assertEquals(blockTextFull, featureBlock.getText());
162
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
163
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
164
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
165
        assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
166

    
167

    
168
        /* Common names */
169
        featureClass = "common-names";
170
        featureLabel = "Common names";
171
        expectedCssDisplay = "block";
172
        blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان7\n7. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000 (as Scariola triquetra (Labill.) Soják)";
173

    
174
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
175
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
176

    
177
        assertEquals(blockTextFull, featureBlock.getText());
178

    
179

    
180
        /* Uses */
181
        featureClass = "credits";
182
        featureLabel = "Credits";
183
        blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
184
        expectedCssDisplay = "block";
185

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

    
189
        assertEquals(blockTextFull, featureBlock.getText());
190
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
191
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
192
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
193
        assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
194

    
195
    }
196

    
197
}
(9-9/10)