This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Fix bugs detected by Sonarcloud after merging branch 250 #263
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,12 +15,14 @@ | |
|
||
import java.time.LocalDateTime; | ||
import java.util.Comparator; | ||
import java.util.Objects; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.JavascriptExecutor; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.StaleElementReferenceException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
|
@@ -225,11 +227,11 @@ public boolean isLoaded() { | |
@Override | ||
public SiteadminActions waitForPageCount(int pageCount) { | ||
boolean conditionNotMet = !webElementUtils.isConditionMet(webDriver -> { | ||
try { | ||
return pageCount == getChildPageWindow().getPageCount(); | ||
} catch (StaleElementReferenceException e) { | ||
webDriver.navigate().refresh(); | ||
return false; | ||
try { | ||
return pageCount == getChildPageWindow().getPageCount(); | ||
} catch (StaleElementReferenceException e) { | ||
Objects.requireNonNull(webDriver).navigate().refresh(); | ||
return false; | ||
} | ||
}, Timeouts.SMALL); | ||
if (conditionNotMet) { | ||
|
@@ -240,11 +242,11 @@ public SiteadminActions waitForPageCount(int pageCount) { | |
|
||
private void waitForExpectedStatus(final String title, ActivationStatus status) { | ||
wait.withTimeout(Timeouts.MEDIUM).until(webDriver -> { | ||
webDriver.navigate().refresh(); | ||
ChildPageRow childPageRow = getChildPageWindow().getChildPageRow(title); | ||
PageActivationStatus pageActivationStatusCell = childPageRow.getPageActivationStatus(); | ||
ActivationStatus activationStatus = pageActivationStatusCell.getActivationStatus(); | ||
return activationStatus == status; | ||
Objects.requireNonNull(webDriver).navigate().refresh(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
ChildPageRow childPageRow = getChildPageWindow().getChildPageRow(title); | ||
PageActivationStatus pageActivationStatusCell = childPageRow.getPageActivationStatus(); | ||
ActivationStatus activationStatus = pageActivationStatusCell.getActivationStatus(); | ||
return activationStatus == status; | ||
}, Timeouts.MINIMAL); | ||
} | ||
|
||
|
@@ -255,8 +257,8 @@ private ChildPageWindow getChildPageWindow() { | |
|
||
private void retryLoad() { | ||
conditions.verify(webDriver -> { | ||
webDriver.navigate().refresh(); | ||
return isLoadedCondition(); | ||
Objects.requireNonNull(webDriver).navigate().refresh(); | ||
return isLoadedCondition(); | ||
}, Timeouts.MEDIUM); | ||
} | ||
|
||
|
@@ -275,7 +277,7 @@ private void navigateInteractively(String destination) { | |
} | ||
wait.withTimeout(Timeouts.SMALL).until((ExpectedCondition<Object>) input -> | ||
"0".equals(((JavascriptExecutor) driver).executeScript("return $.active").toString()) | ||
); | ||
); | ||
navigateInteractively(destination); | ||
} | ||
} | ||
|
@@ -289,11 +291,13 @@ private void goForwardToDestination(String currentUrl, String destination) { | |
getChildPageWindow().getChildPageRows().stream() | ||
.collect(Collectors.toMap(Function.identity(), | ||
childPageRow -> StringUtils.difference(currentUrl, childPageRow.getHref()) | ||
)) | ||
)) | ||
.entrySet() | ||
.stream() | ||
.min(Comparator.comparingInt(a -> a.getValue().length())) | ||
.get() | ||
.orElseThrow(() -> new NoSuchElementException( | ||
String.format( | ||
"Failed to find a child page while trying to reach %s", destination))) | ||
.getKey()); | ||
closestPage.click(); | ||
} | ||
|
@@ -304,11 +308,12 @@ private void goBackUsingNavigator(String destination, String currentUrl) { | |
.filter(path -> !currentUrl.equals(path)) | ||
.collect(Collectors.toMap( | ||
Function.identity(), path -> StringUtils.difference(path, destination) | ||
)) | ||
)) | ||
.entrySet() | ||
.stream() | ||
.min(Comparator.comparingInt(a -> a.getValue().length())) | ||
.get() | ||
.orElseThrow(() -> new IllegalArgumentException( | ||
String.format("Unable to find a path to destination \"%s\"", destination))) | ||
.getKey(); | ||
navigatorDropdown.selectByPath(closestPath); | ||
} | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is redundant, Guice can't inject nulls.