commit 9da7b3ec60c728255c76140018b229910ba23c0b
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue Sep 6 15:22:10 2011 +0000

    tests for #386 (Handle hybrids in data portals)

diff --git a/.gitattributes b/.gitattributes
index e9cb7344..ed3f5899 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -278,6 +278,7 @@ modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etax
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/PortalPage.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonProfilePage.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSearchResultPage.java -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSynonymyPage.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/AllTrue.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/JUnitWebDriverWait.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/PageTitleValidated.java -text
@@ -288,8 +289,10 @@ modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/eu
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/resources/log4j.properties -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/ExampleTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/CichorieaeSearchTest.java -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_HybridTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Allium_guttatum_subsp_guttatum_TaxonProfileTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/CyprusSearchTest.java -text
+modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_HybridTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_OriginalSourceTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/diptera/Diptera_OriginalSourceTest.java -text
 modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/flMalesiana/FloraMalesianaPolytomousKeyTest.java -text
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSynonymyPage.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSynonymyPage.java
new file mode 100644
index 00000000..174579e7
--- /dev/null
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/pages/TaxonSynonymyPage.java
@@ -0,0 +1,127 @@
+// $Id$
+
+/**
+ * Copyright (C) 2009 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+package eu.etaxonomy.dataportal.pages;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.openqa.selenium.By;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.support.CacheLookup;
+import org.openqa.selenium.support.FindBy;
+
+import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.elements.FeatureBlock;
+import eu.etaxonomy.dataportal.elements.ImgElement;
+import eu.etaxonomy.dataportal.elements.LinkElement;
+
+/**
+ * TODO: subpages like /cdm_dataportal/taxon/{uuid}/images are not jet suported, implement means to handle page parts
+ *
+ * @author andreas
+ * @date Jul 1, 2011
+ *
+ */
+public class TaxonSynonymyPage extends PortalPage {
+
+	public static final Logger logger = Logger.getLogger(TaxonSynonymyPage.class);
+
+	private UUID taxonUuid;
+
+	protected static String drupalPagePathBase = "cdm_dataportal/taxon";
+
+	/* (non-Javadoc)
+	 * @see eu.etaxonomy.dataportal.pages.PortalPage#getDrupalPageBase()
+	 */
+	@Override
+	protected String getDrupalPageBase() {
+		return drupalPagePathBase;
+	}
+
+	@FindBy(id = "synonymy")
+	@CacheLookup
+	private WebElement synonymy;
+
+
+
+	/**
+	 * @param driver
+	 * @param context
+	 * @param taxonUuid
+	 * @throws MalformedURLException
+	 */
+	public TaxonSynonymyPage(WebDriver driver, DataPortalContext context, UUID taxonUuid) throws MalformedURLException {
+
+		super(driver, context, taxonUuid.toString() + "/synonymy");
+
+		this.taxonUuid = taxonUuid;
+	}
+
+
+	/**
+	 * @param driver
+	 * @param context
+	 * @throws Exception
+	 */
+	public TaxonSynonymyPage(WebDriver driver, DataPortalContext context) throws Exception {
+		super(driver, context);
+	}
+
+
+	/**
+	 * Returns the profile image of the taxon profile page. This image is
+	 * located at the top of the page. The Profile Image can be disabled in the
+	 * DataPortal settings.
+	 *
+	 * @return The Url of the profile image or null if the image is not visible.
+	 */
+	public String getAcceptedName() {
+		WebElement acceptedName = synonymy.findElement(By.xpath("./span[contains(@class,'accepted-name')]"));
+		return acceptedName.getText();
+	}
+
+	/**
+	 * @param synonymIndex
+	 *            the 1-based position of the synonym in the list of homotypical
+	 *            synonyms
+	 * @return the full text line of the synonym including the prepending symbol
+	 *         and all information rendered after the name. All whitespace is
+	 *         normalized to the SPACE character.
+	 */
+	public String getHomotypicalSynonymName(Integer synonymIndex) {
+		WebElement acceptedName = synonymy.findElement(By.xpath("./ul[contains(@class,'homotypicSynonyms')]/li[" + synonymIndex + "]"));
+		return acceptedName.getText().replaceAll("\\s", " ");
+	}
+
+	/**
+	 * @param heterotypicalGroupIndex
+	 *            the 0-based index of the heterotypical group
+	 * @param synonymIndex
+	 *            the 1-based position of the synonym in the list specified
+	 *            group of heterotypical synonyms
+	 * @return the full text line of the synonym including the prepending symbol
+	 *         and all information rendered after the name. All whitespace is
+	 *         normalized to the SPACE character.
+	 */
+	public String getHeterotypicalSynonymName(Integer heterotypicalGroupIndex, Integer synonymIndex) {
+		WebElement acceptedName = synonymy.findElement(By.xpath("./ul[contains(@class,'heterotypicSynonymyGroup')]/li[" + synonymIndex + "]"));
+		return acceptedName.getText().replaceAll("\\s", " ");
+	}
+}
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/WebDriverFactory.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/WebDriverFactory.java
index 62c8bc9b..24a1cbba 100644
--- a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/WebDriverFactory.java
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/main/java/eu/etaxonomy/dataportal/selenium/WebDriverFactory.java
@@ -76,7 +76,8 @@ public class WebDriverFactory {
 
 		WebDriver driver;
 
-		CdmDataPortalTestBase.logger.info(("firefox binary:" + System.getProperty("webdriver.firefox.bin")));
+		CdmDataPortalTestBase.logger.info(("fwebdriver.firefox.bin = " + System.getProperty("webdriver.firefox.bin")));
+		CdmDataPortalTestBase.logger.info(("webdriver.firefox.library.path = " + System.getProperty("webdriver.firefox.library.path")));
 
 		FirefoxProfile firefoxProfile = new FirefoxProfile();
 		try {
@@ -89,7 +90,6 @@ public class WebDriverFactory {
 
 			firefoxProfile.addExtension(CdmDataPortalTestBase.class, "/org/mozilla/addons/firexpath-" + FIREXPATH_VERSION + "-fx.xpi");
 
-			firefoxProfile.setEnableNativeEvents(true);
 
 			// --- allow enabling incompatible addons
 			// firefoxProfile.addExtension(this.getClass(), "/org/mozilla/addons/add_on_compatibility_reporter-0.8.3-fx+tb+sm.xpi");
@@ -103,6 +103,9 @@ public class WebDriverFactory {
 			CdmDataPortalTestBase.logger.error(e);
 			System.exit(-1);
 		}
+
+		firefoxProfile.setEnableNativeEvents(true);
+
 		driver = new FirefoxDriver(firefoxProfile);
 
 
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_HybridTest.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_HybridTest.java
new file mode 100644
index 00000000..36b16a9e
--- /dev/null
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cichorieae/Cichorieae_HybridTest.java
@@ -0,0 +1,76 @@
+// $Id$
+/**
+ * Copyright (C) 2009 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+package eu.etaxonomy.dataportal.selenium.tests.cichorieae;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.util.UUID;
+
+import org.junit.Test;
+
+import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
+import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
+import eu.etaxonomy.dataportal.pages.TaxonSynonymyPage;
+
+/**
+ *
+ * @author a.kohlbecker
+ *
+ */
+
+@DataPortalContexts( { DataPortalContext.cichorieae })
+public class Cichorieae_HybridTest extends CdmDataPortalTestBase{
+
+
+	static UUID crepis_malyi_Uuid = UUID.fromString("a4050699-ace9-45fb-a807-249531da5566");
+
+	static UUID lactuca_favratii_Uuid = UUID.fromString("6027e1fa-9fe5-4ddc-a2de-f72bfa7378c0");
+
+	static UUID crepis_oenipontana_Uuid = UUID.fromString("31b8757f-6acb-4826-ba7f-b2d116dc713c");
+
+	static UUID crepis_artificialis_Uuid = UUID.fromString("3eabdf89-ddeb-461c-b6f8-341bb8deb7bf");
+
+
+	@Test
+	public void crepis_malyi() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), crepis_malyi_Uuid);
+		String expectedName = "Crepis ×malyi";
+		assertEquals(getContext().prepareTitle(expectedName), p.getTitle());
+		assertEquals("Crepis ×malyi Stadlm. in Oesterr. Bot. Z. 58: 425. 1908", p.getAcceptedName());
+	}
+
+	@Test
+	public void lactuca_favratii() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), lactuca_favratii_Uuid);
+		assertEquals(getContext().prepareTitle("Lactuca ×\"favratii\""), p.getTitle());
+	    assertEquals("Lactuca ×\"favratii\" , nom. provis.", p.getAcceptedName());
+		assertEquals("≡ Cicerbita ×favratii Wilczek in Bull. Soc. Vaud. Sci. Nat. 51: 333. 1917", p.getHomotypicalSynonymName(1));
+	}
+
+	@Test
+	public void crepis_oenipontana() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), crepis_oenipontana_Uuid);
+		assertEquals(getContext().prepareTitle("Crepis ×oenipontana"), p.getTitle());
+	    assertEquals("Crepis ×oenipontana Murr in Österr. Bot. Z. 43: 178. 1893", p.getAcceptedName());
+		assertEquals("= Crepis alpestris f. pseudalpestris Murr in Allg. Bot. Z. Syst. 14: 9. 1908", p.getHeterotypicalSynonymName(1, 1));
+		assertEquals("≡ Crepis alpestris var. pseudalpestris (Murr) Murr in Allg. Bot. Z. Syst. 14: 9. 1908", p.getHeterotypicalSynonymName(1, 2));
+		assertEquals("≡ Crepis ×pseudalpestris (Murr) Murr in Allg. Bot. Z. Syst. 22: 66. 1916", p.getHeterotypicalSynonymName(1, 3));
+	}
+
+	@Test
+	public void crepis_artificialis() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), crepis_artificialis_Uuid);
+		assertEquals(getContext().prepareTitle("Crepis x artificialis"), p.getTitle());
+	    assertEquals("Crepis x artificialis J. Collins & al. in Genetics 14: 310. 1929", p.getAcceptedName());
+	}
+
+}
diff --git a/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_HybridTest.java b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_HybridTest.java
new file mode 100644
index 00000000..7cdf24bf
--- /dev/null
+++ b/modules/cdm_dataportal/test/java/dataportal-selenium-tests/src/test/java/eu/etaxonomy/dataportal/selenium/tests/cyprus/Cyprus_HybridTest.java
@@ -0,0 +1,58 @@
+// $Id$
+/**
+ * Copyright (C) 2009 EDIT
+ * European Distributed Institute of Taxonomy
+ * http://www.e-taxonomy.eu
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1
+ * See LICENSE.TXT at the top of this package for the full license terms.
+ */
+package eu.etaxonomy.dataportal.selenium.tests.cyprus;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.MalformedURLException;
+import java.util.UUID;
+
+import org.junit.Test;
+
+import eu.etaxonomy.dataportal.DataPortalContext;
+import eu.etaxonomy.dataportal.junit.CdmDataPortalTestBase;
+import eu.etaxonomy.dataportal.junit.DataPortalContextSuite.DataPortalContexts;
+import eu.etaxonomy.dataportal.pages.TaxonSynonymyPage;
+
+/**
+ *
+ * @author a.kohlbecker
+ *
+ */
+
+@DataPortalContexts( { DataPortalContext.cyprus })
+public class Cyprus_HybridTest extends CdmDataPortalTestBase{
+
+
+	static UUID orchiserapias_Uuid = UUID.fromString("0aee7eea-84e7-4b61-8cb6-d17313cc9b80");
+
+	static UUID epilobium_aschersonianum_Uuid = UUID.fromString("e13ea422-5d45-477b-ade3-8dc84dbc9dbc");
+
+
+	@Test
+	public void orchiserapias() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), orchiserapias_Uuid);
+		String expectedName = "×Orchiserapias";
+		assertEquals(getContext().prepareTitle(expectedName), p.getTitle());
+		assertEquals(expectedName, p.getAcceptedName());
+		assertEquals("≡ Orchis × Serapias", p.getHomotypicalSynonymName(1));
+	}
+
+	@Test
+	public void epilobium_aschersonianum() throws MalformedURLException {
+		TaxonSynonymyPage p = new TaxonSynonymyPage(driver, getContext(), epilobium_aschersonianum_Uuid);
+		String expectedName = "Epilobium ×aschersonianum Hausskn.";
+		assertEquals(getContext().prepareTitle(expectedName), p.getTitle());
+		assertEquals(expectedName, p.getAcceptedName());
+		assertEquals("≡ Epilobium lanceolatum × parviflorum", p.getHomotypicalSynonymName(1));
+	}
+
+
+}
