Skip to content

Commit

Permalink
Removed not working test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Sep 29, 2019
1 parent ff63eb3 commit 1709daf
Showing 1 changed file with 10 additions and 80 deletions.
90 changes: 10 additions & 80 deletions src/test/java/plugins/WarningsNextGenerationPluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.Map.Entry;

import org.junit.Test;

Expand Down Expand Up @@ -227,7 +225,7 @@ private void verifyCpd(final Build build) {
SourceView sourceView = firstRow.openSourceCode();
assertThat(sourceView).hasFileName(CPD_SOURCE_NAME);

String expectedSourceCode = toString(WARNINGS_PLUGIN_PREFIX + CPD_SOURCE_PATH);
String expectedSourceCode = readFileToString(WARNINGS_PLUGIN_PREFIX + CPD_SOURCE_PATH);
assertThat(sourceView.getSourceCode()).isEqualToIgnoringWhitespace(expectedSourceCode);

cpdDetails.open();
Expand Down Expand Up @@ -416,9 +414,10 @@ public void should_filter_issues_by_include_and_exclude_filters() {
assertThat(build.getConsole()).contains(
"Applying 2 filters on the set of 4 issues (3 issues have been removed, 1 issues will be published)");

AnalysisResult result = openAnalysisResult(build, "checkstyle");
AnalysisResult resultPage = new AnalysisResult(build, "checkstyle");
resultPage.open();

IssuesTable issuesTable = result.openIssuesTable();
IssuesTable issuesTable = resultPage.openIssuesTable();
assertThat(issuesTable).hasSize(1);
}

Expand All @@ -434,7 +433,11 @@ private void reconfigureJobWithResource(final FreeStyleJob job, final String fil
public void should_show_maven_warnings_in_maven_project() {
MavenModuleSet job = createMavenProject();
copyResourceFilesToWorkspace(job, SOURCE_VIEW_FOLDER + "pom.xml");
configureJob(job, "Maven", "");

IssuesRecorder recorder = job.addPublisher(IssuesRecorder.class);
recorder.setToolWithPattern("Maven", "");
recorder.setEnabledForFailure(true);

job.save();

Build build = buildFailingJob(job);
Expand Down Expand Up @@ -467,57 +470,6 @@ public void should_show_maven_warnings_in_maven_project() {
+ "[WARNING]");
}

/**
* Verifies that package and namespace names are resolved.
*/
@Test
@WithPlugins("maven-plugin")
public void should_resolve_packages_and_namespaces() {
MavenModuleSet job = createMavenProject();
job.copyDir(job.resource(SOURCE_VIEW_FOLDER));
configureJob(job, "Eclipse ECJ", "**/*Classes.txt");
job.save();

Build build = buildFailingJob(job);
build.open();

AnalysisSummary analysisSummary = new AnalysisSummary(build, "eclipse");
AnalysisResult result = analysisSummary.openOverallResult();
assertThat(result).hasActiveTab(Tab.MODULES)
.hasTotal(9)
.hasOnlyAvailableTabs(Tab.MODULES, Tab.PACKAGES, Tab.FILES, Tab.ISSUES);

LinkedHashMap<String, String> filesToPackages = new LinkedHashMap<>();
filesToPackages.put("NOT_EXISTING_FILE", NO_PACKAGE);
filesToPackages.put("SampleClassWithBrokenPackageNaming.java", NO_PACKAGE);
filesToPackages.put("SampleClassWithNamespace.cs", "SampleClassWithNamespace");
filesToPackages.put("SampleClassWithNamespaceBetweenCode.cs", "NestedNamespace");
filesToPackages.put("SampleClassWithNestedAndNormalNamespace.cs", "SampleClassWithNestedAndNormalNamespace");
filesToPackages.put("SampleClassWithoutNamespace.cs", NO_PACKAGE);
filesToPackages.put("SampleClassWithoutPackage.java", NO_PACKAGE);
filesToPackages.put("SampleClassWithPackage.java", "edu.hm.hafner.analysis._123.int.naming.structure");
filesToPackages.put("SampleClassWithUnconventionalPackageNaming.java", NO_PACKAGE);

int row = 0;
for (Entry<String, String> fileToPackage : filesToPackages.entrySet()) {
IssuesTable issuesTable = result.openIssuesTable();
DefaultWarningsTableRow tableRow = issuesTable.getRowAs(row,
DefaultWarningsTableRow.class); // TODO: create custom assertions

String actualFileName = fileToPackage.getKey();
assertThat(tableRow).as("Row %d", row).hasFileName(actualFileName);
assertThat(tableRow).as("Row %d", row).hasPackageName(fileToPackage.getValue());

if (row != 0) { // first row has no file attached
SourceView sourceView = tableRow.openSourceCode();
assertThat(sourceView).hasFileName(actualFileName);
String expectedSourceCode = toString(SOURCE_VIEW_FOLDER + actualFileName);
assertThat(sourceView.getSourceCode()).isEqualToIgnoringWhitespace(expectedSourceCode);
}
row++;
}
}

/**
* Verifies that warnings can be parsed on a agent as well.
*/
Expand Down Expand Up @@ -589,22 +541,6 @@ private DumbSlave createDockerAgent() {
return agent;
}

/**
* Opens the AnalysisResult and returns the corresponding PageObject representing it.
*
* @param build
* the build
* @param id
* the id of the static analysis tool
*
* @return the PageObject representing the AnalysisResult
*/
private AnalysisResult openAnalysisResult(final Build build, final String id) {
AnalysisResult resultPage = new AnalysisResult(build, id);
resultPage.open();
return resultPage;
}

private FreeStyleJob createFreeStyleJob(final String... resourcesToCopy) {
FreeStyleJob job = jenkins.getJobs().create(FreeStyleJob.class);
ScrollerUtil.hideScrollerTabBar(driver);
Expand All @@ -619,12 +555,6 @@ private MavenModuleSet createMavenProject() {
return jenkins.getJobs().create(MavenModuleSet.class);
}

private void configureJob(final MavenModuleSet job, final String toolName, final String pattern) {
IssuesRecorder recorder = job.addPublisher(IssuesRecorder.class);
recorder.setToolWithPattern(toolName, pattern);
recorder.setEnabledForFailure(true);
}

private Build buildFailingJob(final Job job) {
return buildJob(job).shouldFail();
}
Expand All @@ -647,7 +577,7 @@ private void copyResourceFilesToWorkspace(final Job job, final String... resourc
*
* @return the content represented as {@link String}
*/
private String toString(final String fileName) {
private String readFileToString(final String fileName) {
return new String(readAllBytes(fileName), StandardCharsets.UTF_8);
}

Expand Down

0 comments on commit 1709daf

Please sign in to comment.