-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from Goodie01/develop
Develop
- Loading branch information
Showing
20 changed files
with
300 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
examples/src/main/java/org/goodiemania/melinoe/samples/github/GithubRepoPullRequestPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package org.goodiemania.melinoe.samples.github; | ||
|
||
import nz.geek.goodwin.melinoe.framework.api.web.BasePage; | ||
import nz.geek.goodwin.melinoe.framework.api.Session; | ||
import nz.geek.goodwin.melinoe.framework.api.web.validation.TitleValidator; | ||
import nz.geek.goodwin.melinoe.framework.api.web.BasePage; | ||
import nz.geek.goodwin.melinoe.framework.api.web.validation.WebValidator; | ||
|
||
public class GithubRepoPullRequestPage extends BasePage { | ||
public GithubRepoPullRequestPage(final Session session) { | ||
super(session, TitleValidator.equals("Pull requests · Goodie01/Melinoe · GitHub")); | ||
super(session, WebValidator.titleEquals("Pull requests · Goodie01/Melinoe · GitHub")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
framework/src/main/java/nz/geek/goodwin/melinoe/framework/api/Validator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nz.geek.goodwin.melinoe.framework.api; | ||
|
||
import nz.geek.goodwin.melinoe.framework.api.rest.HttpResult; | ||
import nz.geek.goodwin.melinoe.framework.api.web.validation.ValidationResult; | ||
|
||
/** | ||
* @author Goodie | ||
*/ | ||
public interface Validator<T> { | ||
ValidationResult validate(final T result); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...rk/src/main/java/nz/geek/goodwin/melinoe/framework/api/rest/validation/RestValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
...rk/src/main/java/nz/geek/goodwin/melinoe/framework/api/web/validation/TitleValidator.java
This file was deleted.
Oops, something went wrong.
26 changes: 25 additions & 1 deletion
26
...work/src/main/java/nz/geek/goodwin/melinoe/framework/api/web/validation/WebValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,34 @@ | ||
package nz.geek.goodwin.melinoe.framework.api.web.validation; | ||
|
||
import nz.geek.goodwin.melinoe.framework.api.Validator; | ||
import nz.geek.goodwin.melinoe.framework.api.web.WebDriver; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.function.ToBooleanBiFunction; | ||
|
||
/** | ||
* @author Goodie | ||
*/ | ||
public interface WebValidator { | ||
public interface WebValidator extends Validator<WebDriver> { | ||
ValidationResult validate(final WebDriver webDriver); | ||
|
||
static WebValidator titleEquals(String title) { | ||
return titleImpl(StringUtils::equals, title); | ||
} | ||
|
||
static WebValidator titleContains(String title) { | ||
return titleImpl(StringUtils::contains, title); | ||
} | ||
|
||
private static WebValidator titleImpl(ToBooleanBiFunction<String, String> comparisonType, String expectedTitle) { | ||
return webDriver -> { | ||
String actualTitle = webDriver.getTitle(); | ||
if (comparisonType.applyAsBoolean(actualTitle, expectedTitle)) { | ||
return ValidationResult.passed("Found expected title: " + expectedTitle); | ||
} else { | ||
return ValidationResult.failed("Title is not as expected", | ||
String.format("Expected title: \"%s\"", expectedTitle), | ||
String.format("Actual title: \"%s\"", actualTitle)); | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.