Project

General

Profile

« Previous | Next » 

Revision a5594ab7

Added by Alex Theys almost 12 years ago

AT: committing Dataportal to Branch post Merge

View differences:

5.x/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Lactuca_triquetra_TaxonProfileTest.java
44 44
@DataPortalContexts( { DataPortalContext.cichorieae })
45 45
public class Lactuca_triquetra_TaxonProfileTest extends CdmDataPortalTestBase{
46 46

  
47
	public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
48

  
49
	static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
50

  
51
	TaxonProfilePage p = null;
52

  
53
	@Before
54
	public void setUp() throws MalformedURLException {
55

  
56
		if(p != null && driver != null ){
57
			logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
58
		}
59
		p = new TaxonProfilePage(driver, getContext(), taxonUuid);
60

  
61
	}
62

  
63

  
64
	@Test
65
	public void testTitleAndTabs() {
66

  
67
		assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
68
		assertNull("Authorship information should be hidden", p.getAuthorInformationText());
69

  
70
		List<LinkElement> primaryTabs = p.getPrimaryTabs();
71
		int tabId = 0;
72
		assertEquals("General", primaryTabs.get(tabId++).getText());
73
		assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
74
		assertEquals("Images", primaryTabs.get(tabId++).getText());
75
		assertEquals("Specimens", primaryTabs.get(tabId++).getText());
76
		assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
77

  
78
	}
79

  
80
	@Test
81
	public void testProfileImage() {
82
		ImgElement profileImage = p.getProfileImage();
83
		assertNotNull("Expecting profile images to be switched on", profileImage);
84
		assertTrue("Expoecting image Lactuca_triquetra_Bc_01.JPG", profileImage.getSrcUrl().toString().endsWith("/Lactuca_triquetra_Bc_01.JPG"));
85
	}
86

  
87

  
88
	@Test
89
	public void testFeatures() {
90
		assertEquals("Content", p.getTableOfContentHeader());
91
		List<LinkElement> links = p.getTableOfContentLinks();
92
		assertNotNull("Expecting a list of TOC links in the profile page.", links);
93

  
94
		FeatureBlock featureBlock;
95
		int featureId = 0;
96

  
97
		int descriptionElementFontSize = 12;
98
		String expectedCssDisplay = "inline";
99
		String expectedListStyleType = "none";
100
		String expectedListStylePosition = "outside";
101
		String expectedListStyleImage = "none";
102
		int indent = 0;
103

  
104
		/* Description */
105
		String featureClass = "description";
106
		String featureLabel = "Description";
107
		String blockTextFull = null;
108
		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.";
109
		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).";
110
		expectedListStyleType = "none";
111

  
112
		p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
113
		featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
114

  
115
		assertTrue(featureBlock.getText().startsWith(blockTextBegin));
116
		assertTrue(featureBlock.getText().endsWith(blockTextEnd));
117
		featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
118
		assertEquals(0, featureBlock.getOriginalSourcesSections().size());
119

  
120
		/* Distribution */
121
		expectedCssDisplay = "block";
122
		featureClass = "distribution";
123
		featureLabel = "Distribution";
124
		blockTextFull = featureLabel + "\n\n\n\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. 19336. (N)";
125
		p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
126
		featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
127

  
128
		assertEquals(blockTextFull, featureBlock.getText());
129

  
130
		MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
131
		logger.info(descriptionElement.getText());
132
		featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
133
		assertEquals(0, featureBlock.getOriginalSourcesSections().size());
134
		assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size());
135
		assertEquals("Expecting 6 Footnotes", 6, featureBlock.getFootNotes().size());
136

  
137
		assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
138
		WebElement mapCaptionElement = null;
139
		try {
140
			mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
141
		} catch (NoSuchElementException e){
142
			/* IGNORE */
143
		}
144
		assertNull(mapCaptionElement);
145

  
146
		/* Uses */
147
		featureClass = "ecology";
148
		featureLabel = "Ecology";
149
		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)";
150
		expectedCssDisplay = "inline";
151

  
152
		p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
153
		featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
154

  
155
		assertEquals(blockTextFull, featureBlock.getText());
156
		featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
157
		assertEquals(0, featureBlock.getOriginalSourcesSections().size());
158
		assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
159
		assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
160

  
161

  
162
		/* Common names */
163
		featureClass = "common_names";
164
		featureLabel = "Common names";
165
		expectedCssDisplay = "block";
166
		blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان7\n7. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000";
167

  
168
		p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
169
		featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
170

  
171
		assertEquals(blockTextFull, featureBlock.getText());
172

  
173

  
174
		/* Uses */
175
		featureClass = "credits";
176
		featureLabel = "Credits";
177
		blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
178
		expectedCssDisplay = "block";
179

  
180
		p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
181
		featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
182

  
183
		assertEquals(blockTextFull, featureBlock.getText());
184
		featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
185
		assertEquals(0, featureBlock.getOriginalSourcesSections().size());
186
		assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
187
		assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
188

  
189
	}
47
    public static final Logger logger = Logger.getLogger(Lactuca_triquetra_TaxonProfileTest.class);
48

  
49
    static UUID taxonUuid = UUID.fromString("ecb7a76e-694a-4706-b1ab-a2eb334173ff");
50

  
51
    TaxonProfilePage p = null;
52

  
53
    @Before
54
    public void setUp() throws MalformedURLException {
55

  
56
        if(p != null && driver != null ){
57
            logger.debug("TaxonProfilePage p:" + p.getPageURL() + ", driver is at " + driver.getCurrentUrl());
58
        }
59
        p = new TaxonProfilePage(driver, getContext(), taxonUuid);
60

  
61
    }
62

  
63

  
64
    @Test
65
    public void testTitleAndTabs() {
66

  
67
        assertEquals(getContext().prepareTitle("Lactuca triquetra"), p.getTitle());
68
        assertNull("Authorship information should be hidden", p.getAuthorInformationText());
69

  
70
        List<LinkElement> primaryTabs = p.getPrimaryTabs();
71
        int tabId = 0;
72
        assertEquals("General", primaryTabs.get(tabId++).getText());
73
        assertEquals("Synonymy", primaryTabs.get(tabId++).getText());
74
        assertEquals("Images", primaryTabs.get(tabId++).getText());
75
        assertEquals("Specimens", primaryTabs.get(tabId++).getText());
76
        assertEquals("Expecting " + tabId + " tabs", tabId, primaryTabs.size());
77

  
78
    }
79

  
80
    @Test
81
    public void testProfileImage() {
82
        ImgElement profileImage = p.getProfileImage();
83
        assertNotNull("Expecting profile images to be switched on", profileImage);
84
        assertTrue("Expecting image Lactuca_triquetra_Bc_01.JPG", profileImage.getSrcUrl().toString().endsWith("/Lactuca_triquetra_Bc_01.JPG"));
85
    }
86

  
87

  
88
    @Test
89
    public void testFeatures() {
90
        assertEquals("Content", p.getTableOfContentHeader());
91
        List<LinkElement> links = p.getTableOfContentLinks();
92
        assertNotNull("Expecting a list of TOC links in the profile page.", links);
93

  
94
        FeatureBlock featureBlock;
95
        int featureId = 0;
96

  
97
        int descriptionElementFontSize = 12;
98
        String expectedCssDisplay = "inline";
99
        String expectedListStyleType = "none";
100
        String expectedListStylePosition = "outside";
101
        String expectedListStyleImage = "none";
102
        int indent = 0;
103

  
104
        /* Description */
105
        String featureClass = "description";
106
        String featureLabel = "Description";
107
        String blockTextFull = null;
108
        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.";
109
        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).";
110
        expectedListStyleType = "none";
111

  
112
        p.testTableOfContentEntry(featureId++,featureLabel, featureClass);
113
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
114

  
115
        assertTrue(featureBlock.getText().startsWith(blockTextBegin));
116
        assertTrue(featureBlock.getText().endsWith(blockTextEnd));
117
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
118
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
119

  
120
        /* Distribution */
121
        expectedCssDisplay = "block";
122
        featureClass = "distribution";
123
        featureLabel = "Distribution";
124
        blockTextFull = featureLabel + "\n\n\n\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. 19336. (N)";
125
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
126
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "dt", "dd");
127

  
128
        assertEquals(blockTextFull, featureBlock.getText());
129

  
130
        MultipartDescriptionElementRepresentation descriptionElement = (MultipartDescriptionElementRepresentation) featureBlock.getDescriptionElements().get(0);
131
        logger.info(descriptionElement.getText());
132
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
133
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
134
        assertEquals("Expecting 7 FootnoteKeys", 7, featureBlock.getFootNoteKeys().size());
135
        assertEquals("Expecting 6 Footnotes", 6, featureBlock.getFootNotes().size());
136

  
137
        assertNotNull("Expecting an OpenLayers map", featureBlock.getElement().findElement(By.id("openlayers_map")));
138
        WebElement mapCaptionElement = null;
139
        try {
140
            mapCaptionElement = featureBlock.getElement().findElement(By.className("distribution_map_caption"));
141
        } catch (NoSuchElementException e){
142
            /* IGNORE */
143
        }
144
        assertNull(mapCaptionElement);
145

  
146
        /* Uses */
147
        featureClass = "ecology";
148
        featureLabel = "Ecology";
149
        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)";
150
        expectedCssDisplay = "inline";
151

  
152
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
153
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
154

  
155
        assertEquals(blockTextFull, featureBlock.getText());
156
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
157
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
158
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
159
        assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
160

  
161

  
162
        /* Common names */
163
        featureClass = "common_names";
164
        featureLabel = "Common names";
165
        expectedCssDisplay = "block";
166
        blockTextFull = featureLabel + "\nArabic (Lebanon): سْكَرْيولَة ثُلاثِيَّة الأَرْكان7\n7. Nehmé, M., Dictionnaire Etymologique de la Flore du Liban. 2000";
167

  
168
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
169
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "li");
170

  
171
        assertEquals(blockTextFull, featureBlock.getText());
172

  
173

  
174
        /* Uses */
175
        featureClass = "credits";
176
        featureLabel = "Credits";
177
        blockTextFull = featureLabel + "\nChristodoulou C. S. 2009: Images (1 added).\nMakris C. 2009: Images (1 added).";
178
        expectedCssDisplay = "block";
179

  
180
        p.testTableOfContentEntry(featureId++, featureLabel, featureClass);
181
        featureBlock = p.getFeatureBlockAt(featureId, featureClass, "div", "span");
182

  
183
        assertEquals(blockTextFull, featureBlock.getText());
184
        featureBlock.testDescriptionElementLayout(0, indent, descriptionElementFontSize, expectedCssDisplay, expectedListStyleType, expectedListStylePosition, expectedListStyleImage);
185
        assertEquals(0, featureBlock.getOriginalSourcesSections().size());
186
        assertEquals("Expecting no FootnoteKeys", 0, featureBlock.getFootNoteKeys().size());
187
        assertEquals("Expecting no Footnotes", 0, featureBlock.getFootNotes().size());
188

  
189
    }
190 190

  
191 191
}

Also available in: Unified diff