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.Test;
|
20
|
import org.openqa.selenium.By;
|
21
|
import org.openqa.selenium.WebElement;
|
22
|
|
23
|
import eu.etaxonomy.dataportal.DataPortalSite;
|
24
|
import eu.etaxonomy.dataportal.DrupalVars;
|
25
|
import eu.etaxonomy.dataportal.ElementUtils;
|
26
|
import eu.etaxonomy.dataportal.elements.BaseElement;
|
27
|
import eu.etaxonomy.dataportal.elements.DescriptionList;
|
28
|
import eu.etaxonomy.dataportal.elements.DescriptionList.DescriptionElement;
|
29
|
import eu.etaxonomy.dataportal.elements.LinkElement;
|
30
|
import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
|
31
|
import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
|
32
|
import eu.etaxonomy.dataportal.pages.TaxonPage;
|
33
|
import eu.etaxonomy.drush.DrushExecuter;
|
34
|
import eu.etaxonomy.drush.DrushExecutionFailure;
|
35
|
|
36
|
/**
|
37
|
* @author a.kohlbecker
|
38
|
* @since Aug 11, 2020
|
39
|
*/
|
40
|
@DataPortalContexts( { DataPortalSite.reference })
|
41
|
public class SpecimensTreeViewTest extends CdmDataPortalTestBase {
|
42
|
|
43
|
public static final Logger logger = Logger.getLogger(DrushExecuter.class);
|
44
|
|
45
|
private static final UUID glenodinium_apiculatum_t = UUID.fromString("d245083e-3bda-435f-9bb3-bdc2249ff23c");
|
46
|
|
47
|
|
48
|
|
49
|
@Before
|
50
|
public void switchToView() throws IOException, InterruptedException, DrushExecutionFailure {
|
51
|
Logger.getLogger(DrushExecuter.class).setLevel(Level.DEBUG);
|
52
|
setDrupalVar(DrupalVars.CDM_DATAPORTAL_TAXONPAGE_TABS, "1");
|
53
|
setDrupalVar(DrupalVars.CDM_SPECIMEN_LIST_VIEW_MODE, "derivate_tree");
|
54
|
}
|
55
|
|
56
|
@Test
|
57
|
public void test1() throws MalformedURLException {
|
58
|
TaxonPage p = new TaxonPage(driver, getContext(), glenodinium_apiculatum_t, "specimens");
|
59
|
WebElement specimensTable = p.getDataPortalContent().getElement().findElement(By.cssSelector("#specimens table.derivate_tree"));
|
60
|
List<WebElement> summaryRows = specimensTable.findElements(By.cssSelector("tr.summary_row"));
|
61
|
List<WebElement> detailRows = specimensTable.findElements(By.cssSelector("tr.detail_row"));
|
62
|
assertEquals(3, summaryRows.size());
|
63
|
assertEquals("Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047.", summaryRows.get(0).getText());
|
64
|
assertEquals("Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047.", summaryRows.get(1).getText());
|
65
|
assertEquals("Germany, Berlin, 2 Apr 1835.", summaryRows.get(2).getText());
|
66
|
|
67
|
|
68
|
// Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28.3.2016, D047.
|
69
|
summaryRows.get(0).click(); // make the row visible
|
70
|
|
71
|
WebElement descriptionListContainerElement = detailRows.get(0).findElement(By.cssSelector("div.description_list"));
|
72
|
WebElement derivateTreeContainer = descriptionListContainerElement.findElement(By.xpath("./parent::li"));
|
73
|
logger.debug("derivateTreeContainer: " + ElementUtils.webElementTagToMarkup(derivateTreeContainer));
|
74
|
|
75
|
List<WebElement> dls = detailRows.get(0).findElements(By.cssSelector("div.description_list"));
|
76
|
assertEquals(3, dls.size());
|
77
|
DescriptionList dl1 = new DescriptionList(dls.get(0).findElement(By.tagName("dl")));
|
78
|
assertEquals("Field Unit", dl1.joinedDescriptionElementText("Record base:"));
|
79
|
assertEquals("Germany", dl1.joinedDescriptionElementText("Country:"));
|
80
|
assertEquals("Berlin", dl1.joinedDescriptionElementText("Locality:"));
|
81
|
BaseElement descriptionListContainer = new BaseElement(derivateTreeContainer);
|
82
|
assertEquals(3, descriptionListContainer.getLinksInElement().size()); // other links in the derivate tree are also found
|
83
|
LinkElement link1 = descriptionListContainer.getLinksInElement().get(0);
|
84
|
assertEquals("Detail page", link1.getText());
|
85
|
assertTrue(link1.getUrl().endsWith("/cdm_dataportal/occurrence/89d36e79-3e80-4468-986e-411ca391452e"));
|
86
|
|
87
|
DescriptionList dl2 = new DescriptionList(dls.get(1).findElement(By.tagName("dl")));
|
88
|
|
89
|
assertEquals("Preserved Specimen", dl2.joinedDescriptionElementText("Record base:"));
|
90
|
assertEquals("2017E68", dl2.joinedDescriptionElementText("Accession number:"));
|
91
|
assertEquals("\nCode:\nCEDiT", dl2.joinedDescriptionElementText("Collection"));
|
92
|
assertEquals("Specimen", dl2.joinedDescriptionElementText("Kind of unit:"));
|
93
|
assertEquals("Epitype: Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047 (CEDiT 2017E68).",
|
94
|
dl2.joinedDescriptionElementText("Specimen type designations:"));
|
95
|
DescriptionElement specimenTypeDesignation_dd = dl2.getDescriptionGroups().get("Specimen type designations:").get(0);
|
96
|
List<LinkElement> specimenTypeDesignationLinks = specimenTypeDesignation_dd.getDescriptionElementContent().getLinksInElement();
|
97
|
assertEquals(1, specimenTypeDesignationLinks.size());
|
98
|
assertEquals("CEDiT 2017E68", specimenTypeDesignationLinks.get(0).getText());
|
99
|
assertTrue(specimenTypeDesignationLinks.get(0).getUrl().endsWith("cdm_dataportal/occurrence/8585081c-b73b-440b-b349-582845cf3fb4"));
|
100
|
|
101
|
// Germany, Berlin, 52°31'1.2"N, 13°21'E, 28.3.2016, D047.
|
102
|
summaryRows.get(1).click(); // make the row visible
|
103
|
descriptionListContainerElement = detailRows.get(1).findElement(By.cssSelector("div.description_list"));
|
104
|
derivateTreeContainer = descriptionListContainerElement.findElement(By.xpath("./parent::li"));
|
105
|
|
106
|
dls = detailRows.get(1).findElements(By.cssSelector("div.description_list"));
|
107
|
assertEquals(3, dls.size());
|
108
|
dl1 = new DescriptionList(dls.get(0).findElement(By.tagName("dl")));
|
109
|
assertEquals("Field Unit", dl1.joinedDescriptionElementText("Record base:"));
|
110
|
assertEquals("Germany", dl1.joinedDescriptionElementText("Country:"));
|
111
|
assertEquals("Berlin", dl1.joinedDescriptionElementText("Locality:"));
|
112
|
descriptionListContainer = new BaseElement(derivateTreeContainer);
|
113
|
assertEquals(5, descriptionListContainer.getLinksInElement().size()); // other links in the derivate tree are also found
|
114
|
link1 = descriptionListContainer.getLinksInElement().get(0);
|
115
|
assertEquals("Detail page", link1.getText());
|
116
|
assertTrue(link1.getUrl().endsWith("/cdm_dataportal/occurrence/89d36e79-3e80-4468-986e-411ca391452e"));
|
117
|
|
118
|
dl2 = new DescriptionList(dls.get(1).findElement(By.tagName("dl")));
|
119
|
|
120
|
assertEquals("Preserved Specimen", dl2.joinedDescriptionElementText("Record base:"));
|
121
|
assertEquals("M-0289351", dl2.joinedDescriptionElementText("Accession number:"));
|
122
|
assertEquals("\nCode:\nM", dl2.joinedDescriptionElementText("Collection"));
|
123
|
assertEquals("Specimen", dl2.joinedDescriptionElementText("Kind of unit:"));
|
124
|
assertEquals("Isolectotype: Germany, Berlin, 52°31'1.2\"N, 13°21'E, 28 Mar 2016, D047 (M M-0289351). http://herbarium.bgbm.org/object/B400042045",
|
125
|
dl2.joinedDescriptionElementText("Specimen type designations:"));
|
126
|
specimenTypeDesignationLinks = dl2.getDescriptionGroups().get("Specimen type designations:").get(0).getDescriptionElementContent().getLinksInElement();
|
127
|
assertEquals(2, specimenTypeDesignationLinks.size());
|
128
|
assertEquals("M M-0289351", specimenTypeDesignationLinks.get(0).getText());
|
129
|
assertTrue(specimenTypeDesignationLinks.get(0).getUrl().endsWith("cdm_dataportal/occurrence/e86c5acd-de55-44af-99f7-484207657264"));
|
130
|
assertEquals("http://herbarium.bgbm.org/object/B400042045", specimenTypeDesignationLinks.get(1).getText());
|
131
|
assertEquals("http://herbarium.bgbm.org/object/B400042045", specimenTypeDesignationLinks.get(1).getUrl().toString());
|
132
|
|
133
|
}
|
134
|
|
135
|
}
|