Project

General

Profile

Download (15.1 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
import java.util.stream.Collectors;
16

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

    
23
import eu.etaxonomy.dataportal.DataPortalSite;
24
import eu.etaxonomy.dataportal.DrupalVars;
25
import eu.etaxonomy.dataportal.elements.BaseElement;
26
import eu.etaxonomy.dataportal.elements.DerivedUnitTree;
27
import eu.etaxonomy.dataportal.elements.DerivedUnitTreeNode;
28
import eu.etaxonomy.dataportal.elements.DetailsTable;
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
    private TaxonPage p;
48

    
49
    List<DerivedUnitTree> duTrees;
50

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

    
59
    // must be called after setting the drupal vars
60
    public void loadPage() throws MalformedURLException {
61
        p = new TaxonPage(driver, getContext(), glenodinium_apiculatum_t, "specimens");
62
        duTrees = p.getDataPortalContent().getElement().findElements(By.cssSelector(".derived-unit-tree")).stream()
63
                .map(el -> DerivedUnitTree.from(el))
64
                .collect(Collectors.toList());
65
    }
66

    
67
    @Test
68
    public void testPage() {
69

    
70
        assertEquals(3, duTrees.size());
71
        BaseElement rootNodeHeader1 = duTrees.get(0).getRootNode().getHeader();
72
        assertEquals("(B SP-99999).", rootNodeHeader1.getText());
73
        BaseElement rootNodeHeader2 = duTrees.get(1).getRootNode().getHeader();
74
        assertEquals("Germany, Berlin, 2 Apr 1835.", rootNodeHeader2.getText());
75
        BaseElement rootNodeHeader3 = duTrees.get(2).getRootNode().getHeader();
76
        assertEquals("Germany, Berlin, alt. 165 m, 52°31'1.2\"N, 13°21'E (WGS84), 28 Mar 2016, Ehrenberg D047.", rootNodeHeader3.getText());
77
    }
78

    
79

    
80
    @Test
81
    public void testDerivationTree1() {
82

    
83
        DerivedUnitTree tree1 = duTrees.get(0);
84
        DerivedUnitTreeNode rootNode = tree1.getRootNode();
85
        DerivedUnitTreeNode subNode1 = rootNode.getSubNodes().get(0);
86
        DerivedUnitTreeNode subNode2 = rootNode.getSubNodes().get(1);
87
        DerivedUnitTreeNode subNode3 = rootNode.getSubNodes().get(2);
88

    
89
        assertEquals("(B SP-99999).", rootNode.getHeader().getText());
90
        assertEquals("(B B-923845).", subNode1.getHeader().getText());
91
        assertEquals("(B DNA-9098080).", subNode2.getHeader().getText());
92
        assertEquals("B_SP-99999.png", subNode3.getHeader().getText());
93

    
94
        // NOTE we are only testing subnode 1 here as all other details are tested in other methods
95

    
96
        // ---- sub node 1
97
        subNode1.getHeader().getElement().click(); // make the  content visible
98
        LinkElement pageLink = subNode1.getHeader().getLinksInElement().get(0);
99
        assertTrue(pageLink.getUrl().endsWith("/cdm_dataportal/occurrence/2d424df6-f927-472a-8fb5-4c2d2eeb4484"));
100

    
101
        // THIS THE THE MOST IMORTANT detail to test here
102
        assertEquals("Preparation: Liebm., Botanic Garden and Botanical Museum Berlin-Dahlem (BGBM), 2020-01-03", subNode1.getDerivationEvent());
103

    
104
        DetailsTable tissueSampleTable = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Tissue Sample"));
105
        assertEquals("Tissue Sample", tissueSampleTable.getHeaderText());
106
        assertEquals("fruit", tissueSampleTable.getDetailsValueCellText("Kind of unit"));
107
        assertEquals("B-923845", tissueSampleTable.getDetailsValueCellText("Accession number"));
108
        assertEquals("B", tissueSampleTable.getDetailsValueCellText("Collection"));
109

    
110
    }
111

    
112

    
113
    @Test
114
    public void testDerivationTree2() {
115

    
116
        DerivedUnitTree tree2 = duTrees.get(1);
117
        DerivedUnitTreeNode rootNode = tree2.getRootNode();
118
        DerivedUnitTreeNode subNode1 = rootNode.getSubNodes().get(0);
119

    
120
        assertEquals("Germany, Berlin, 2 Apr 1835.", rootNode.getHeader().getText());
121
        assertEquals("BHUPM 671 (ECdraw671.jpg)", subNode1.getHeader().getText());
122

    
123
        // ---- root node
124
        rootNode.getHeader().getElement().click(); // make the  content visible
125
        LinkElement pageLink = rootNode.getHeader().getLinksInElement().get(0);
126
        assertTrue(pageLink.getUrl().endsWith("cdm_dataportal/occurrence/75b73483-7ee6-4c2c-8826-1e58a0ed18e0"));
127

    
128
        DetailsTable fieldUnitTable = rootNode.getDetailsTable(DetailsTable.tableClassAttrFrom("Field Unit"));
129
        assertEquals("Field Unit", fieldUnitTable.getHeaderText());
130
        assertEquals("field note 1", fieldUnitTable.getDetailsValueCellText("Field notes"));
131

    
132
        DetailsTable gatheringTable = rootNode.getDetailsTable(DetailsTable.tableClassAttrFrom("Gathering & Location"));
133
        assertEquals("Gathering & Location", gatheringTable.getHeaderText());
134
        assertEquals("Germany", gatheringTable.getDetailsValueCellText("Country"));
135
        assertEquals("Berlin", gatheringTable.getDetailsValueCellText("Locality"));
136
        assertEquals("1835-04-02", gatheringTable.getDetailsValueCellText("Date"));
137

    
138
        // ---- sub node 1
139
        subNode1.getHeader().getElement().click(); // make the  content visible
140
        pageLink = subNode1.getHeader().getLinksInElement().get(0);
141
        assertTrue(pageLink.getUrl().endsWith("cdm_dataportal/occurrence/eb729673-5206-49fb-b902-9214d8bdbb51"));
142

    
143
        assertEquals("Gathering in-situ", subNode1.getDerivationEvent());
144

    
145
        DetailsTable imageTable = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Still Image"));
146
        assertEquals("Still Image", imageTable.getHeaderText());
147
        assertEquals("Unpublished image", imageTable.getDetailsValueCellText("Kind of unit"));
148
        assertEquals("671", imageTable.getDetailsValueCellText("Accession number"));
149
        assertEquals("BHUPM", imageTable.getDetailsValueCellText("Collection"));
150

    
151
        DetailsTable typeDesignationsTable = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Type designations"));
152
        assertEquals("Lectotype (designated by Kretschmann, J., Žerdoner ?alasan, A. & Kusber, W.-H. 20171)",
153
                typeDesignationsTable.getBodyCellText(0, 0));
154

    
155
    }
156

    
157

    
158
    @Test
159
    public void testDerivationTree3() {
160

    
161
        DerivedUnitTree tree3 = duTrees.get(2);
162
        DerivedUnitTreeNode rootNode = tree3.getRootNode();
163
        DerivedUnitTreeNode subNode1 = rootNode.getSubNodes().get(0);
164
        DerivedUnitTreeNode subNode1_1 = subNode1.getSubNodes().get(0);
165
        DerivedUnitTreeNode subNode1_2 = subNode1.getSubNodes().get(1);
166
        DerivedUnitTreeNode subNode2 = rootNode.getSubNodes().get(1);
167

    
168
        assertEquals("Germany, Berlin, alt. 165 m, 52°31'1.2\"N, 13°21'E (WGS84), 28 Mar 2016, Ehrenberg D047.", rootNode.getHeader().getText());
169
        assertEquals("Germany, Berlin, alt. 165 m, 52°31'1.2\"N, 13°21'E (WGS84), 28 Mar 2016, Ehrenberg D047; D. Veloper (CEDiT 2017E68).", subNode1.getHeader().getText());
170
        assertEquals("B IMG 99999 (?fn%3dIMG%2099999.jpg%26mo%3dfile)", subNode1_1.getHeader().getText());
171
        assertEquals("XKCD MASKS 2X (Masks)", subNode1_2.getHeader().getText());
172
        assertEquals("Germany, Berlin, alt. 165 m, 52°31'1.2\"N, 13°21'E (WGS84), 28 Mar 2016, Ehrenberg D047 (M M-0289351).", subNode2.getHeader().getText());
173

    
174
        // --- Root note
175
        rootNode.getHeader().getElement().click(); // make the  content visible
176
        LinkElement pageLink = rootNode.getHeader().getLinksInElement().get(0);
177
        assertTrue(pageLink.getUrl().endsWith("/cdm_dataportal/occurrence/89d36e79-3e80-4468-986e-411ca391452e"));
178

    
179
        DetailsTable fieldUnitTable = rootNode.getDetailsTable(DetailsTable.tableClassAttrFrom("Field Unit"));
180
        assertEquals("Field Unit", fieldUnitTable.getHeaderText());
181
        assertEquals("D047", fieldUnitTable.getDetailsValueCellText("Collecting number"));
182

    
183
        DetailsTable gatheringTable = rootNode.getDetailsTable(DetailsTable.tableClassAttrFrom("Gathering & Location"));
184
        assertEquals("Gathering & Location", gatheringTable.getHeaderText());
185
        assertEquals("2016-03-28", gatheringTable.getDetailsValueCellText("Date"));
186
        assertEquals("Ehrenberg, C.G.", gatheringTable.getDetailsValueCellText("Collector"));
187
        assertEquals("Berlin", gatheringTable.getDetailsValueCellText("Locality"));
188
        assertEquals("Germany", gatheringTable.getDetailsValueCellText("Country"));
189
        assertEquals("52°31'1.2\"N, 13°21'E +/-20 m (WGS84)", gatheringTable.getDetailsValueCellText("Exact location"));
190
        assertEquals("165 m", gatheringTable.getDetailsValueCellText("Altitude"));
191

    
192
        // --- node 1
193

    
194
        subNode1.getHeader().getElement().click();
195
        assertTrue(subNode1.getHeader().getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/occurrence/8585081c-b73b-440b-b349-582845cf3fb4"));
196

    
197
        assertEquals("Gathering in-situ", subNode1.getDerivationEvent());
198

    
199
        DetailsTable preserverdSpecimenTable_1 = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Preserved Specimen"));
200
        assertEquals("Preserved Specimen", preserverdSpecimenTable_1.getHeaderText());
201
        assertEquals("Specimen", preserverdSpecimenTable_1.getDetailsValueCellText("Kind of unit"));
202
        assertEquals("2017E68", preserverdSpecimenTable_1.getDetailsValueCellText("Accession number"));
203
        assertEquals("http://testid.org/2017E68", preserverdSpecimenTable_1.getDetailsValueCellText("Preferred stable uri"));
204
        assertEquals("http://testid.org/2017E68", preserverdSpecimenTable_1.getDetailsValueCell("Preferred stable uri").getLinksInElement().get(0).getUrl());
205
        assertEquals("CEDiT at Botanic Garden and Botanical Museum Berlin-Dahlem (BGBM)", preserverdSpecimenTable_1.getDetailsValueCellText("Collection"));
206
        assertEquals("Glenodinium apiculatum", preserverdSpecimenTable_1.getDetailsValueCellText("Stored under"));
207
        assertTrue(preserverdSpecimenTable_1.getDetailsValueCell("Stored under").getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/name/758a9b10-6817-496b-b5a3-dd66b38c13b0/null/null/"));
208
        assertEquals("D. Veloper", preserverdSpecimenTable_1.getDetailsValueCellText("Exsiccatum"));
209
        assertEquals("CE_2017E68", preserverdSpecimenTable_1.getDetailsValueCellText("Catalog number"));
210
        assertEquals("E2017E68", preserverdSpecimenTable_1.getDetailsValueCellText("Barcode"));
211

    
212
        DetailsTable typeDesignationsTable_1 = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Type designations"));
213
        assertEquals("Epitype (designated by Kretschmann, J., Žerdoner ?alasan, A. & Kusber, W.-H. 20171)",
214
                typeDesignationsTable_1.getBodyCellText(0, 0));
215

    
216
        DetailsTable identificationsTable_1 = subNode1.getDetailsTable(DetailsTable.tableClassAttrFrom("Identification"));
217
        assertEquals("Glenodinium apiculatum",
218
                identificationsTable_1.getBodyCellText(0, 0));
219
        assertTrue(identificationsTable_1.getBodyCell(0, 0).getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/taxon/d245083e-3bda-435f-9bb3-bdc2249ff23c"));
220

    
221
        // --- --- node_1_1
222

    
223
        subNode1_1.getHeader().getElement().click();
224
        assertTrue(subNode1_1.getHeader().getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/occurrence/a825bdad-6854-4868-98f5-7e6ebe3b6271"));
225

    
226
        assertEquals("Accessioning", subNode1_1.getDerivationEvent());
227

    
228
        DetailsTable imageTable_1_1 = subNode1_1.getDetailsTable(DetailsTable.tableClassAttrFrom("Still Image"));
229
        assertEquals("Still Image", imageTable_1_1.getHeaderText());
230
        assertEquals("Specimen scan", imageTable_1_1.getDetailsValueCellText("Kind of unit"));
231
        assertEquals("IMG 99999", imageTable_1_1.getDetailsValueCellText("Accession number"));
232
        assertEquals("B", imageTable_1_1.getDetailsValueCellText("Collection"));
233

    
234
        DetailsTable mediaTable_1_1 = subNode1_1.getDetailsTable(DetailsTable.tableClassAttrFrom("Media"));
235
        assertTrue(mediaTable_1_1.getBodyCell(0, 0).getText().contains("?fn%3dIMG%2099999.jpg%26mo%3dfile"));
236

    
237

    
238
        // --- --- node_1_2
239

    
240
        subNode1_2.getHeader().getElement().click();
241
        assertTrue(subNode1_2.getHeader().getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/occurrence/c2495af1-251b-42e9-b5ab-2e3e0df9ea3f"));
242

    
243
        assertEquals("Accessioning", subNode1_2.getDerivationEvent());
244

    
245
        DetailsTable imageTable_1_2 = subNode1_2.getDetailsTable(DetailsTable.tableClassAttrFrom("Still Image"));
246
        assertEquals("Still Image", imageTable_1_2.getHeaderText());
247
        assertEquals("Detail image", imageTable_1_2.getDetailsValueCellText("Kind of unit"));
248
        assertEquals("MASKS 2X", imageTable_1_2.getDetailsValueCellText("Accession number"));
249
        assertEquals("XKCD", imageTable_1_2.getDetailsValueCellText("Collection"));
250

    
251
        DetailsTable mediaTable_1_2 = subNode1_2.getDetailsTable(DetailsTable.tableClassAttrFrom("Media"));
252
        assertTrue(mediaTable_1_2.getBodyCell(0, 0).getText().contains("Ink drawing"));
253

    
254

    
255
        // --- node_2
256

    
257
        subNode2.getHeader().getElement().click();
258
        assertTrue(subNode2.getHeader().getLinksInElement().get(0).getUrl().endsWith("/cdm_dataportal/occurrence/e86c5acd-de55-44af-99f7-484207657264"));
259

    
260
        assertEquals("Gathering in-situ", subNode2.getDerivationEvent());
261

    
262
        DetailsTable preserverdSpecimenTable_2 = subNode2.getDetailsTable(DetailsTable.tableClassAttrFrom("Preserved Specimen"));
263
        assertEquals("Preserved Specimen", preserverdSpecimenTable_2.getHeaderText());
264
        assertEquals("http://herbarium.bgbm.org/object/B400042045", preserverdSpecimenTable_2.getDetailsValueCellText("Preferred stable uri"));
265
        assertEquals("Specimen", preserverdSpecimenTable_2.getDetailsValueCellText("Kind of unit"));
266

    
267
        DetailsTable typeDesignationsTable_2 = subNode2.getDetailsTable(DetailsTable.tableClassAttrFrom("Type designations"));
268
        assertEquals("Isolectotype (designated by Kretschmann, J., Žerdoner ?alasan, A. & Kusber, W.-H. 20171)",
269
                typeDesignationsTable_2.getBodyCellText(0, 0));
270
        assertEquals("expecting one footnote key link", 1, typeDesignationsTable_2.getBodyCell(0, 0).getLinksInElement().size());
271

    
272
    }
273

    
274
}
(13-13/15)