Project

General

Profile

Download (8.23 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2020 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.IOException;
12
import java.net.MalformedURLException;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import org.apache.log4j.Level;
17
import org.apache.log4j.Logger;
18
import org.junit.Before;
19
import org.junit.Ignore;
20
import org.junit.Test;
21
import org.openqa.selenium.By;
22
import org.openqa.selenium.WebElement;
23

    
24
import eu.etaxonomy.dataportal.DataPortalSite;
25
import eu.etaxonomy.dataportal.DrupalVars;
26
import eu.etaxonomy.dataportal.ElementUtils;
27
import eu.etaxonomy.dataportal.elements.BaseElement;
28
import eu.etaxonomy.dataportal.elements.DescriptionList;
29
import eu.etaxonomy.dataportal.elements.DescriptionList.DescriptionElement;
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.TaxonPage;
34
import eu.etaxonomy.drush.DrushExecuter;
35
import eu.etaxonomy.drush.DrushExecutionFailure;
36

    
37
/**
38
 * @author a.kohlbecker
39
 * @since Aug 11, 2020
40
 */
41
@DataPortalContexts( { DataPortalSite.reference })
42
public class SpecimensTreeViewTest extends CdmDataPortalTestBase {
43

    
44
    public static final Logger logger = Logger.getLogger(DrushExecuter.class);
45

    
46
    private static final UUID glenodinium_apiculatum_t = UUID.fromString("d245083e-3bda-435f-9bb3-bdc2249ff23c");
47

    
48

    
49

    
50
    @Before
51
    public void switchToView() throws IOException, InterruptedException, DrushExecutionFailure {
52
        Logger.getLogger(DrushExecuter.class).setLevel(Level.DEBUG);
53
        setDrupalVar(DrupalVars.CDM_DATAPORTAL_TAXONPAGE_TABS, "1");
54
        setDrupalVar(DrupalVars.CDM_SPECIMEN_LIST_VIEW_MODE, "derivate_tree");
55
    }
56

    
57
    @Test
58
    @Ignore // see #9234
59
    public void test1() throws MalformedURLException {
60
        TaxonPage p = new TaxonPage(driver, getContext(), glenodinium_apiculatum_t, "specimens");
61
        WebElement specimensTable = p.getDataPortalContent().getElement().findElement(By.cssSelector("#specimens table.derivate_tree"));
62
        List<WebElement> summaryRows = specimensTable.findElements(By.cssSelector("tr.summary_row"));
63
        List<WebElement> detailRows = specimensTable.findElements(By.cssSelector("tr.detail_row"));
64
        assertEquals(3, summaryRows.size());
65
        assertEquals("Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047.", summaryRows.get(0).getText());
66
        assertEquals("Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047.", summaryRows.get(1).getText());
67
        assertEquals("Germany, Berlin, 2 Apr 1835.", summaryRows.get(2).getText());
68

    
69

    
70
        // Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28.3.2016, D047.
71
        summaryRows.get(0).click(); // make the row visible
72

    
73
        WebElement descriptionListContainerElement = detailRows.get(0).findElement(By.cssSelector("div.description_list"));
74
        WebElement derivateTreeContainer = descriptionListContainerElement.findElement(By.xpath("./parent::li"));
75
        logger.debug("derivateTreeContainer: " + ElementUtils.webElementTagToMarkup(derivateTreeContainer));
76

    
77
        List<WebElement> dls = detailRows.get(0).findElements(By.cssSelector("div.description_list"));
78
        assertEquals(3, dls.size());
79
        DescriptionList dl1 = new DescriptionList(dls.get(0).findElement(By.tagName("dl")));
80
        assertEquals("Field Unit", dl1.joinedDescriptionElementText("Record base:"));
81
        assertEquals("Germany", dl1.joinedDescriptionElementText("Country:"));
82
        assertEquals("Berlin", dl1.joinedDescriptionElementText("Locality:"));
83
        BaseElement descriptionListContainer = new BaseElement(derivateTreeContainer);
84
        assertEquals(4, descriptionListContainer.getLinksInElement().size()); // other links in the derivate tree are also found
85
        // TODO one of the links is a footnote key for which the footnote is missing
86
        LinkElement link1 = descriptionListContainer.getLinksInElement().get(0);
87
        assertEquals("Detail page", link1.getText());
88
        assertTrue(link1.getUrl().endsWith("/cdm_dataportal/occurrence/89d36e79-3e80-4468-986e-411ca391452e"));
89

    
90
        DescriptionList dl2 = new DescriptionList(dls.get(1).findElement(By.tagName("dl")));
91

    
92
        assertEquals("Preserved Specimen", dl2.joinedDescriptionElementText("Record base:"));
93
        assertEquals("2017E68", dl2.joinedDescriptionElementText("Accession number:"));
94
        assertEquals("\nCode:\nCEDiT", dl2.joinedDescriptionElementText("Collection"));
95
        assertEquals("Specimen", dl2.joinedDescriptionElementText("Kind of unit:"));
96
        assertEquals("Epitype (designated by Kretschmann, J., Žerdoner ?alasan, A. & Kusber, W.-H. 20171): Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047 (CEDiT 2017E68).",
97
                dl2.joinedDescriptionElementText("Specimen type designations:"));
98
        DescriptionElement specimenTypeDesignation_dd = dl2.getDescriptionGroups().get("Specimen type designations:").get(0);
99
        List<LinkElement> specimenTypeDesignationLinks = specimenTypeDesignation_dd.getDescriptionElementContent().getLinksInElement();
100
        assertEquals(2, specimenTypeDesignationLinks.size());
101
        // TODO one of the links is a footnote key for which the footnote is missing
102
        assertEquals("CEDiT 2017E68", specimenTypeDesignationLinks.get(1).getText());
103
        assertTrue(specimenTypeDesignationLinks.get(1).getUrl().endsWith("cdm_dataportal/occurrence/8585081c-b73b-440b-b349-582845cf3fb4"));
104

    
105
        // Germany, Berlin, 52°31'1.2"N, 13°21'E, 28.3.2016, D047.
106
        summaryRows.get(1).click(); // make the row visible
107
        descriptionListContainerElement = detailRows.get(1).findElement(By.cssSelector("div.description_list"));
108
        derivateTreeContainer = descriptionListContainerElement.findElement(By.xpath("./parent::li"));
109

    
110
        dls = detailRows.get(1).findElements(By.cssSelector("div.description_list"));
111
        assertEquals(3, dls.size());
112
        dl1 = new DescriptionList(dls.get(0).findElement(By.tagName("dl")));
113
        assertEquals("Field Unit", dl1.joinedDescriptionElementText("Record base:"));
114
        assertEquals("Germany", dl1.joinedDescriptionElementText("Country:"));
115
        assertEquals("Berlin", dl1.joinedDescriptionElementText("Locality:"));
116
        descriptionListContainer = new BaseElement(derivateTreeContainer);
117
        assertEquals(6, descriptionListContainer.getLinksInElement().size()); // other links in the derivate tree are also found
118
        link1 = descriptionListContainer.getLinksInElement().get(0);
119
        assertEquals("Detail page", link1.getText());
120
        assertTrue(link1.getUrl().endsWith("/cdm_dataportal/occurrence/89d36e79-3e80-4468-986e-411ca391452e"));
121

    
122
        dl2 = new DescriptionList(dls.get(1).findElement(By.tagName("dl")));
123

    
124
        assertEquals("Preserved Specimen", dl2.joinedDescriptionElementText("Record base:"));
125
        assertEquals("M-0289351", dl2.joinedDescriptionElementText("Accession number:"));
126
        assertEquals("\nCode:\nM", dl2.joinedDescriptionElementText("Collection"));
127
        assertEquals("Specimen", dl2.joinedDescriptionElementText("Kind of unit:"));
128
        assertEquals("Isolectotype (designated by Kretschmann, J., Žerdoner ?alasan, A. & Kusber, W.-H. 20172): Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047 (M M-0289351). http://herbarium.bgbm.org/object/B400042045",
129
                dl2.joinedDescriptionElementText("Specimen type designations:"));
130
        specimenTypeDesignationLinks = dl2.getDescriptionGroups().get("Specimen type designations:").get(0).getDescriptionElementContent().getLinksInElement();
131
        assertEquals(3, specimenTypeDesignationLinks.size());
132
        assertEquals("M M-0289351", specimenTypeDesignationLinks.get(1).getText());
133
        assertTrue(specimenTypeDesignationLinks.get(1).getUrl().endsWith("cdm_dataportal/occurrence/e86c5acd-de55-44af-99f7-484207657264"));
134
        assertEquals("http://herbarium.bgbm.org/object/B400042045", specimenTypeDesignationLinks.get(2).getText());
135
        assertEquals("http://herbarium.bgbm.org/object/B400042045", specimenTypeDesignationLinks.get(2).getUrl().toString());
136

    
137
    }
138

    
139
}
(10-10/12)