mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
added selenium test case for boat creation
This commit is contained in:
+5
@@ -67,6 +67,11 @@ public class MockedTrackedRaceWithFixedRank extends MockedTrackedRace {
|
||||
return MockedTrackedRaceWithFixedRank.this.competitorsAndBoats.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Competitor, Boat> getCompetitorsAndTheirBoats() {
|
||||
return MockedTrackedRaceWithFixedRank.this.competitorsAndBoats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClass getBoatClass() {
|
||||
return boatClass;
|
||||
|
||||
+5
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.test.mock;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.base.Boat;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
@@ -33,6 +34,10 @@ public class MockedTrackedRaceWithFixedRankAndManyCompetitors extends MockedTrac
|
||||
return competitorsAndBoats.values();
|
||||
}
|
||||
@Override
|
||||
public Map<Competitor, Boat> getCompetitorsAndTheirBoats() {
|
||||
return competitorsAndBoats;
|
||||
}
|
||||
@Override
|
||||
public Competitor getCompetitorById(Serializable competitorID) {
|
||||
for (Competitor competitor : competitorsAndBoats.keySet()) {
|
||||
if (competitorID.equals(competitor.getId())) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.base;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.common.RaceCompetitorIdsAsStringWithMD5Hash;
|
||||
import com.sap.sse.common.NamedWithID;
|
||||
@@ -28,6 +29,8 @@ public interface RaceDefinition extends NamedWithID {
|
||||
|
||||
Competitor getCompetitorById(Serializable competitorID);
|
||||
|
||||
Map<Competitor, Boat> getCompetitorsAndTheirBoats();
|
||||
|
||||
/**
|
||||
* Gets the boat used by the competitor for this race.
|
||||
*/
|
||||
|
||||
+5
@@ -84,6 +84,11 @@ public class RaceDefinitionImpl extends NamedImpl implements RaceDefinition {
|
||||
return Collections.unmodifiableCollection(competitorsAndTheirBoats.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Competitor, Boat> getCompetitorsAndTheirBoats() {
|
||||
return Collections.unmodifiableMap(competitorsAndTheirBoats);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getCompetitorMD5() {
|
||||
return raceCompetitorsMD5Hash.getMd5OfIdsAsStringOfCompetitorParticipatingInRaceInAlphanumericOrderOfTheirID();
|
||||
|
||||
-1
@@ -62,7 +62,6 @@ public class DummyMarkPassingWithTimePointOnly implements MarkPassing {
|
||||
public Boat getBoat() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IsManagedByCache<SharedDomainFactory> resolve(SharedDomainFactory domainFactory) {
|
||||
return this;
|
||||
|
||||
+41
-41
@@ -1,41 +1,41 @@
|
||||
package com.sap.sailing.selenium.pages.adminconsole.tracking;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.common.DataEntryDialogPO;
|
||||
|
||||
public class TrackedRacesCompetitorCreateDialogPO extends DataEntryDialogPO {
|
||||
@FindBy(how = BySeleniumId.class, using = "NameTextBox")
|
||||
private WebElement nameTextBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "SailIdTextBox")
|
||||
private WebElement sailIdTextBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "BoatClassNameSuggestBox")
|
||||
private WebElement boatClassNameSuggestBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "OkButton")
|
||||
private WebElement okButton;
|
||||
|
||||
public TrackedRacesCompetitorCreateDialogPO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
}
|
||||
|
||||
public void setNameTextBox(String name) {
|
||||
this.nameTextBox.clear();
|
||||
this.nameTextBox.sendKeys(name);
|
||||
}
|
||||
|
||||
public void setSailIdTextBox(String sailId) {
|
||||
this.sailIdTextBox.clear();
|
||||
this.sailIdTextBox.sendKeys(sailId);
|
||||
}
|
||||
|
||||
public void setBoatClassNameSuggestBox(String boatClassName) {
|
||||
this.boatClassNameSuggestBox.clear();
|
||||
this.boatClassNameSuggestBox.sendKeys(boatClassName);
|
||||
}
|
||||
}
|
||||
package com.sap.sailing.selenium.pages.adminconsole.tracking;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.common.DataEntryDialogPO;
|
||||
|
||||
public class TrackedRacesBoatEditDialogPO extends DataEntryDialogPO {
|
||||
@FindBy(how = BySeleniumId.class, using = "NameTextBox")
|
||||
private WebElement nameTextBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "SailIdTextBox")
|
||||
private WebElement sailIdTextBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "BoatClassNameSuggestBox")
|
||||
private WebElement boatClassNameSuggestBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "OkButton")
|
||||
private WebElement okButton;
|
||||
|
||||
public TrackedRacesBoatEditDialogPO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
}
|
||||
|
||||
public void setNameTextBox(String name) {
|
||||
this.nameTextBox.clear();
|
||||
this.nameTextBox.sendKeys(name);
|
||||
}
|
||||
|
||||
public void setSailIdTextBox(String sailId) {
|
||||
this.sailIdTextBox.clear();
|
||||
this.sailIdTextBox.sendKeys(sailId);
|
||||
}
|
||||
|
||||
public void setBoatClassNameSuggestBox(String boatClassName) {
|
||||
this.boatClassNameSuggestBox.clear();
|
||||
this.boatClassNameSuggestBox.sendKeys(boatClassName);
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.sap.sailing.selenium.pages.adminconsole.tracking;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import com.sap.sailing.selenium.pages.gwt.CellTablePO;
|
||||
import com.sap.sailing.selenium.pages.gwt.DataEntryPO;
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.ActionsHelper;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesBoatTablePO.BoatEntry;
|
||||
|
||||
public class TrackedRacesBoatTablePO extends CellTablePO<BoatEntry> {
|
||||
public static class BoatEntry extends DataEntryPO {
|
||||
@FindBy(how = BySeleniumId.class, using = "ACTION_EDIT")
|
||||
private WebElement editButton;
|
||||
|
||||
private static final String NAME_COLUMN = "Name";
|
||||
private static final String SAILID_COLUMN = "Sail number";
|
||||
private static final String BOATCLASSNAME_COLUMN = "Boat Class";
|
||||
private static final String ID_COLUMN = "ID";
|
||||
|
||||
protected BoatEntry(TrackedRacesBoatTablePO table, WebElement element) {
|
||||
super(table, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return getColumnContent(ID_COLUMN);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getColumnContent(NAME_COLUMN);
|
||||
}
|
||||
|
||||
public String getSailId() {
|
||||
return getColumnContent(SAILID_COLUMN);
|
||||
}
|
||||
|
||||
public String getBoatClassName() {
|
||||
return getColumnContent(BOATCLASSNAME_COLUMN);
|
||||
}
|
||||
|
||||
public TrackedRacesCompetitorEditDialogPO clickEditButton() {
|
||||
WebElement action = ActionsHelper.findEditAction(getWebElement());
|
||||
action.click();
|
||||
WebElement dialog = findElementBySeleniumId(this.driver, "BoatEditDialog");
|
||||
return new TrackedRacesCompetitorEditDialogPO(this.driver, dialog);
|
||||
}
|
||||
}
|
||||
|
||||
public TrackedRacesBoatTablePO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BoatEntry createDataEntry(WebElement element) {
|
||||
return new BoatEntry(this, element);
|
||||
}
|
||||
}
|
||||
+22
@@ -8,6 +8,12 @@ import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.PageArea;
|
||||
|
||||
public class TrackedRacesBoatsPanelPO extends PageArea {
|
||||
@FindBy(how = BySeleniumId.class, using = "RefreshButton")
|
||||
private WebElement refreshButton;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "AddBoatButton")
|
||||
private WebElement addButton;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "BoatsTable")
|
||||
private WebElement boatsTable;
|
||||
|
||||
@@ -17,4 +23,20 @@ public class TrackedRacesBoatsPanelPO extends PageArea {
|
||||
super(driver, element);
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public TrackedRacesBoatEditDialogPO pushAddButton() {
|
||||
this.addButton.click();
|
||||
waitForAjaxRequests();
|
||||
WebElement dialog = findElementBySeleniumId(this.driver, "BoatEditDialog");
|
||||
return new TrackedRacesBoatEditDialogPO(this.driver, dialog);
|
||||
}
|
||||
|
||||
public void pushRefreshButton() {
|
||||
this.refreshButton.click();
|
||||
waitForAjaxRequests();
|
||||
}
|
||||
|
||||
public TrackedRacesBoatTablePO getBoatsTable() {
|
||||
return new TrackedRacesBoatTablePO(this.driver, this.boatsTable);
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.sap.sailing.selenium.test.adminconsole;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesBoatEditDialogPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesBoatTablePO.BoatEntry;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesBoatsPanelPO;
|
||||
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
|
||||
|
||||
public class TestBoatCreation extends AbstractSeleniumTest {
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
clearState(getContextRoot());
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenCreateBoatDialog() {
|
||||
final TrackedRacesBoatsPanelPO competitorsPanel = goToBoatsPanel();
|
||||
final TrackedRacesBoatEditDialogPO dialog = competitorsPanel.pushAddButton(); // fails with an exception if the dialog is not found
|
||||
assertNotNull(dialog);
|
||||
}
|
||||
|
||||
private TrackedRacesBoatsPanelPO goToBoatsPanel() {
|
||||
final AdminConsolePage adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
|
||||
final TrackedRacesBoatsPanelPO boatsPanel = adminConsole.goToTrackedRacesBoats();
|
||||
return boatsPanel;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBoatCreation() {
|
||||
final TrackedRacesBoatsPanelPO boatsPanel = goToBoatsPanel();
|
||||
final TrackedRacesBoatEditDialogPO dialog = boatsPanel.pushAddButton();
|
||||
final String name = ""+System.currentTimeMillis();
|
||||
dialog.setNameTextBox(name);
|
||||
String sailId = ""+System.currentTimeMillis();
|
||||
dialog.setSailIdTextBox(sailId);
|
||||
final String boatClassName = "49er";
|
||||
dialog.setBoatClassNameSuggestBox(boatClassName);
|
||||
dialog.pressOk();
|
||||
boolean found = false;
|
||||
for (final BoatEntry it : boatsPanel.getBoatsTable().getEntries()) {
|
||||
String itName = it.getName();
|
||||
if (itName.equals(name)) {
|
||||
found = true;
|
||||
// found a candidate:
|
||||
assertEquals(sailId, it.getSailId());
|
||||
assertEquals(boatClassName, it.getBoatClassName());
|
||||
}
|
||||
}
|
||||
assertTrue(found);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user