Project

General

Profile

« Previous | Next » 

Revision c47414aa

Added by Andreas Kohlbecker over 3 years ago

ref #8850 test for footnotes in registration and name pages; footnote support in BaseElement

View differences:

src/main/java/eu/etaxonomy/dataportal/elements/BaseElement.java
23 23
import org.openqa.selenium.support.ui.ExpectedCondition;
24 24
import org.openqa.selenium.support.ui.WebDriverWait;
25 25

  
26
import eu.etaxonomy.dataportal.ElementUtils;
27

  
26 28
/**
27 29
 * @author Andreas Kohlbecker
28 30
 * @since Jul 1, 2011
......
97 99
        return linksInElement;
98 100
    }
99 101

  
102
    public List<LinkElement> getFootNoteKeys(){
103
        return ElementUtils.linkElementsFromFootNoteKeyListElements(
104
                getElement().findElements(By.xpath("//*[contains(@class, 'footnote-key')]/a"))
105
                );
106
    }
107

  
108
    public List<BaseElement> getFootNotes(){
109
        return ElementUtils.baseElementsFromFootNoteListElements(
110
                getElement().findElements(By.xpath("//*[contains(@class, 'footnotes')]/span[contains(@class, 'footnote')]"))
111
                );
112
    }
113

  
100 114
    /**
101 115
     *
102 116
     * @param driver the currently used  WebDriver instance
src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java
346 346
        return tabs;
347 347
    }
348 348

  
349
    /**
350
     * Provides access to the the CDM specific content which is put into the <code>div</code> DOM element which has the class attribute <code>class="... node ..."</code>
351
     * @return
352
     */
353
    public BaseElement getDataPortalContent() {
354
        return new BaseElement(portalContent);
355
    }
356

  
349 357
    public ClassificationTreeBlock getClassificationTree() {
350 358
        return new ClassificationTreeBlock(classificationBrowserBlock);
351 359
    }
src/test/java/eu/etaxonomy/dataportal/selenium/tests/reference/FootnoteTest.java
1
/**
2
* Copyright (C) 2019 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.reference;
10

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

  
16
import org.junit.Before;
17
import org.junit.Test;
18

  
19
import eu.etaxonomy.dataportal.DataPortalSite;
20
import eu.etaxonomy.dataportal.elements.BaseElement;
21
import eu.etaxonomy.dataportal.elements.LinkElement;
22
import eu.etaxonomy.dataportal.elements.RegistrationItemFull;
23
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
24
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
25
import eu.etaxonomy.dataportal.pages.NamePage;
26
import eu.etaxonomy.dataportal.pages.RegistrationPage;
27

  
28
/**
29
 * @author a.kohlbecker
30
 * @since Feb 5, 2019
31
 *
32
 */
33
@DataPortalContexts( { DataPortalSite.reference })
34
public class FootnoteTest extends CdmDataPortalTestBase {
35

  
36

  
37
    private static final String nodosilinea_radiophila_regid = "http://testbank.org/100004";
38

  
39
    private static final String ramsaria_regid = "http://testbank.org/100005";
40

  
41
    private static final UUID nodosilinea_radiophila_name_UUID = UUID.fromString("e97cc25b-ec11-4bb8-88d7-ab40a023f3fb");
42

  
43
    private static final UUID ramsaria_name_UUID = UUID.fromString("3a6d4bf2-5c89-4525-9e87-0bacac96990b");
44

  
45

  
46
    String titleSuffix = " | Integration test reference";
47

  
48

  
49

  
50
    @Before
51
    public void setUp() throws Exception {
52
        driver.get(getContext().getBaseUri().toString());
53
    }
54

  
55
    @Test
56
    public void registationPageFieldUnitAnnotation() throws MalformedURLException, UnsupportedEncodingException{
57

  
58
        RegistrationPage p = new RegistrationPage(driver, getContext(), nodosilinea_radiophila_regid);
59

  
60
        assertEquals("Registration Id: http://testbank.org/100004" + titleSuffix, driver.getTitle());
61
        RegistrationItemFull regItem = p.getRegistrationItem();
62
        assertNotNull(regItem);
63

  
64
        List<LinkElement> footnoteKeys = regItem.getFootNoteKeys();
65
        assertEquals(3, footnoteKeys.size());
66
        // check footnote keys are in right order
67
        assertEquals("1", footnoteKeys.get(0).getText());
68
        assertEquals("2", footnoteKeys.get(1).getText());
69
        assertEquals("3", footnoteKeys.get(2).getText());
70

  
71
        // check content of footnotes
72
        List<BaseElement> footnotes = regItem.getFootNotes();
73
        assertEquals(3, footnotes.size());
74
        assertEquals("1. editorial note on the fieldunit", footnotes.get(0).getText());
75
        assertEquals("2. Art. 77.7 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 22",
76
                footnotes.get(1).getText());
77
        assertEquals("3. Art. 99.9 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 11",
78
                footnotes.get(2).getText());
79
    }
80

  
81
    @Test
82
    public void namePageFieldUnitAnnotation() throws MalformedURLException{
83

  
84
        NamePage p = new NamePage(driver, getContext(), nodosilinea_radiophila_name_UUID);
85

  
86
        assertEquals("Nodosilinea radiophila Heidari & Hauer in Fottea 18(2): 142. fig. 5C, D. 1 Nov 2018" + titleSuffix, driver.getTitle());
87
        BaseElement pageContent = p.getDataPortalContent();
88
        assertNotNull(pageContent);
89

  
90
        List<LinkElement> footnoteKeys = pageContent.getFootNoteKeys();
91
        assertEquals(4, footnoteKeys.size());
92
        // check footnote keys are in right order
93
        assertEquals("1", footnoteKeys.get(0).getText());
94
        assertEquals("2", footnoteKeys.get(1).getText());
95
        assertEquals("3", footnoteKeys.get(2).getText());
96
        assertEquals("4", footnoteKeys.get(3).getText());
97

  
98
        // check content of footnotes
99
        List<BaseElement> footnotes = pageContent.getFootNotes();
100
        assertEquals(4, footnotes.size());
101
        assertEquals("1. Art. 77.7 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 22",
102
                footnotes.get(0).getText());
103
        assertEquals("2. Art. 99.9 Turland, N.J., Wiersema, J.H., Barrie, F.R. & al., International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017: 11",
104
                footnotes.get(1).getText());
105
        BaseElement footnote3 = footnotes.get(2);
106
        assertEquals("3. Heidari, F. & Hauer, T. - in Heidari, F., Zima, J., Riahi, H. & al., New simple trichal cyanobacterial taxa isolated from radioactive thermal springs in Fottea 18(2): 137–149. 2018 Registration: http://testbank.org/100004, 2019-02-06",
107
                        footnote3.getText());
108
        List<LinkElement> linksInFootnote3 = footnote3.getLinksInElement();
109
        assertEquals(2, linksInFootnote3.size());
110
        assertTrue(linksInFootnote3.get(0).getUrl().endsWith("/cdm_dataportal/reference/f2e43411-2564-42c7-816e-7e6046adbefa"));
111
        assertEquals("", linksInFootnote3.get(0).getText());
112
        assertEquals("http://testbank.org/100004", linksInFootnote3.get(1).getText());
113
        assertTrue(linksInFootnote3.get(1).getUrl().endsWith("cdm_dataportal/registration/http%253A%252F%252Ftestbank.org%252F100004"));
114
        assertEquals("4. editorial note on the fieldunit", footnotes.get(3).getText());
115
    }
116

  
117
    @Test
118
    public void registationPageTypeNameAnnotation() throws MalformedURLException, UnsupportedEncodingException{
119

  
120
        RegistrationPage p = new RegistrationPage(driver, getContext(), ramsaria_regid);
121

  
122
        RegistrationItemFull regItem = p.getRegistrationItem();
123
        assertNotNull(regItem);
124

  
125
        List<LinkElement> footnoteKeys = regItem.getFootNoteKeys();
126
        assertEquals(1, footnoteKeys.size());
127
        // check footnote keys are in right order
128
        assertEquals("1", footnoteKeys.get(0).getText());
129

  
130
        // check content of footnotes
131
        List<BaseElement> footnotes = regItem.getFootNotes();
132
        assertEquals(1, footnotes.size());
133
        assertEquals("1. editorial note on the type name of Ramsaria", footnotes.get(0).getText());
134

  
135
    }
136

  
137
    @Test
138
    public void namePageTypeNameAnnotation() throws MalformedURLException{
139

  
140
        NamePage p = new NamePage(driver, getContext(), ramsaria_name_UUID);
141

  
142
        assertEquals("Ramsaria Heidari & Hauer in Fottea 18(2): 146. 1 Nov 2018" + titleSuffix, driver.getTitle());
143
        BaseElement pageContent = p.getDataPortalContent();
144
        assertNotNull(pageContent);
145

  
146
        List<LinkElement> footnoteKeys = pageContent.getFootNoteKeys();
147
        assertEquals(2, footnoteKeys.size());
148
        // check footnote keys are in right order
149
        assertEquals("1", footnoteKeys.get(0).getText());
150
        assertEquals("2", footnoteKeys.get(1).getText());
151

  
152
        // check content of footnotes
153
        List<BaseElement> footnotes = pageContent.getFootNotes();
154
        assertEquals(2, footnotes.size());
155
        BaseElement footnote1 = footnotes.get(1);
156
        assertEquals("1. editorial note on the type name of Ramsaria", footnotes.get(0).getText());
157
        assertEquals("2. Species solaris", footnote1.getText());
158
        List<LinkElement> linksInFootnote3 = footnote1.getLinksInElement();
159
        assertEquals(1, linksInFootnote3.size());
160
        assertTrue(linksInFootnote3.get(0).getUrl().endsWith("cdm_dataportal/reference/5e5d9d08-8c28-4b22-b30a-6214c8641163"));
161
    }
162

  
163
}

Also available in: Unified diff