Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-26913] Added test case that verifies the tab contents of a m…
…atrix build.
  • Loading branch information
uhafner committed Feb 23, 2015
1 parent 37f8c8e commit b5f5397
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
Expand Up @@ -192,7 +192,7 @@ protected List<String> asTrimmedStringList(final List<WebElement> elems) {
}

/**
* Returns the first two columns of the "Categories"-tab as key => value pairs, skipping the header and footer
* Returns the first two columns of the "Files"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
Expand All @@ -202,6 +202,28 @@ public SortedMap<String, Integer> getFileTabContents() {
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Packages"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
*/
public SortedMap<String, Integer> getPackagesTabContents() {
openTab(Tab.PACKAGES);
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Modules"-tab as key => value pairs, skipping the header and footer
* rows.
*
* @return a map of the first two columns. (first column => second column)
*/
public SortedMap<String, Integer> getModulesTabContents() {
openTab(Tab.MODULES);
return getContentsOfVisibleTable(true, true);
}

/**
* Returns the first two columns of the "Categories"-tab as key => value pairs, skipping the header and footer
* rows.
Expand Down Expand Up @@ -374,6 +396,6 @@ public Integer getLinkedSourceFileLineNumber(final Tab tabId, final String fileN
}

public enum Tab {
FILES, PACKAGES, WARNINGS, DETAILS, FIXED, NEW, CATEGORIES, TYPES
MODULES, FILES, PACKAGES, WARNINGS, DETAILS, FIXED, NEW, CATEGORIES, TYPES
}
}
34 changes: 33 additions & 1 deletion src/test/java/plugins/WarningsPluginTest.java
Expand Up @@ -2,6 +2,8 @@

import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

import org.apache.commons.lang3.StringUtils;
import org.jenkinsci.test.acceptance.junit.Bug;
Expand Down Expand Up @@ -45,7 +47,7 @@ public class WarningsPluginTest extends AbstractAnalysisTest {
* also verified (4, 6, and 2 warnings).
*/
// TODO: run the job twice and check for the graphs
@Test @Bug("11225")
@Test @Bug({"11225", "26913"})
public void should_report_warnings_per_axis() {
String file = "matrix-warnings.txt";
MatrixProject job = setupJob("/warnings_plugin/" + file, MatrixProject.class,
Expand Down Expand Up @@ -78,6 +80,36 @@ public void configure(WarningsBuildSettings settings) {
assertThat(driver, hasContent(title + ": " + warningsPerAxis.get(axis.name)));
}

assertThatConfigurationTabIsCorrectlyFilled(job);
assertThatFoldersTabIsCorrectlyFilled(job);
assertThatFilesTabIsCorrectlyFilled(job);
}

private void assertThatConfigurationTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
expectedConfigurationDetails.put("user_axis=one", 4);
expectedConfigurationDetails.put("user_axis=two", 6);
expectedConfigurationDetails.put("user_axis=three", 2);
WarningsAction action = new WarningsAction(job);
assertThat(action.getModulesTabContents(), is(expectedConfigurationDetails));
}

private void assertThatFoldersTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
expectedConfigurationDetails.put("axis/one", 4);
expectedConfigurationDetails.put("axis/two", 6);
expectedConfigurationDetails.put("axis/three", 2);
WarningsAction action = new WarningsAction(job);
assertThat(action.getPackagesTabContents(), is(expectedConfigurationDetails));
}

private void assertThatFilesTabIsCorrectlyFilled(final MatrixProject job) {
SortedMap<String, Integer> expectedConfigurationDetails = new TreeMap<>();
WarningsAction action = new WarningsAction(job);
expectedConfigurationDetails.put("FileOne.c", 4);
expectedConfigurationDetails.put("FileTwo.c", 6);
expectedConfigurationDetails.put("FileThree.c", 2);
assertThat(action.getFileTabContents(), is(expectedConfigurationDetails));
}

/**
Expand Down

0 comments on commit b5f5397

Please sign in to comment.