Skip to content

Commit

Permalink
Cleanup code.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jun 12, 2022
1 parent b6dd25a commit 4d765fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
public class Summary extends PageObject {
private static final Pattern REMOVE_DETAILS = Pattern.compile("(\\r?\\n|\\r).*");

private final String id;

private final WebElement summary;
private final List<WebElement> results;
private final WebElement summarySpan;
private final String title;
private final List<String> details;

Expand All @@ -40,12 +37,9 @@ public class Summary extends PageObject {
public Summary(final Build parent, final String id) {
super(parent, parent.url(id));

this.id = id;

summary = getElement(By.id(id));
title = REMOVE_DETAILS.matcher(summary.getText()).replaceAll("");
results = summary.findElements(by.xpath("ul/li"));
details = results.stream()
summarySpan = getElement(By.id(id));
title = REMOVE_DETAILS.matcher(summarySpan.getText()).replaceAll("");
details = summarySpan.findElements(by.xpath("ul/li")).stream()
.map(WebElement::getText)
.map(StringUtils::normalizeSpace)
.collect(Collectors.toList());
Expand Down Expand Up @@ -78,7 +72,7 @@ public List<String> getDetails() {
* @return the URL of the page that has been opened by the link
*/
public String openLinkByText(final String text) {
summary.findElement(By.linkText(text)).click();
summarySpan.findElement(By.linkText(text)).click();

return driver.getCurrentUrl();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.List;

import org.junit.Test;
import org.openqa.selenium.By;

import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
Expand All @@ -24,9 +23,6 @@ public class ForensicsPluginUiTest extends AbstractJUnitTest {
private static final String REPOSITORY_URL = "https://github.com/jenkinsci/git-forensics-plugin.git";
private static final String SCM_KEY = "git " + REPOSITORY_URL;
private static final int SCM_HASH = SCM_KEY.hashCode();
private static final int GIT_SUMMARY_ROW = 2;
private static final int COMMIT_RECORDER_ROW = 3;
private static final int MINER_ROW = 4;

/**
* Verifies the Git miner by running a build with the forensics plugin analyzing a commit hash of the
Expand Down Expand Up @@ -84,11 +80,6 @@ private WorkflowJob createJob() {
return job;
}

private String getSummaryText(final Build referenceBuild, final int row) {
return referenceBuild.getElement(
By.xpath("/html/body/div[4]/div[2]/table/tbody/tr[" + row + "]/td[2]")).getText();
}

/**
* asserts the headers of the table by their size and entries.
*
Expand Down

0 comments on commit 4d765fa

Please sign in to comment.