|
1 | 1 | package io.jenkins.plugins.analysis.warnings.steps;
|
2 | 2 |
|
3 |
| -import java.io.File; |
4 |
| -import java.io.IOException; |
5 |
| -import java.nio.file.Files; |
6 |
| -import java.nio.file.Path; |
7 |
| -import java.util.ArrayList; |
8 |
| -import java.util.Collections; |
9 |
| -import java.util.List; |
10 |
| -import java.util.Objects; |
11 |
| -import java.util.Set; |
12 |
| -import java.util.stream.Collectors; |
13 |
| - |
14 | 3 | import org.eclipse.collections.impl.factory.Lists;
|
15 | 4 | import org.junit.jupiter.api.DisplayName;
|
16 | 5 | import org.junit.jupiter.api.Test;
|
|
22 | 11 | import edu.hm.hafner.analysis.Report;
|
23 | 12 | import edu.hm.hafner.analysis.Severity;
|
24 | 13 |
|
| 14 | +import java.io.File; |
| 15 | +import java.io.IOException; |
| 16 | +import java.nio.file.Files; |
| 17 | +import java.nio.file.Path; |
| 18 | +import java.util.ArrayList; |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Objects; |
| 22 | +import java.util.Set; |
| 23 | +import java.util.stream.Collectors; |
| 24 | + |
25 | 25 | import org.kohsuke.stapler.HttpResponse;
|
26 | 26 | import org.jenkinsci.Symbol;
|
27 | 27 | import org.jenkinsci.plugins.workflow.actions.WarningAction;
|
@@ -580,37 +580,64 @@ void shouldFailBuildWhenFailBuildOnErrorsIsSet() {
|
580 | 580 | scheduleBuildAndAssertStatus(job, Result.FAILURE);
|
581 | 581 | }
|
582 | 582 |
|
583 |
| - @Test |
584 |
| - void shouldReportResultWithDifferentIdNameAndIconInStep() { |
585 |
| - WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("emptyFile.txt"); |
| 583 | + @ParameterizedTest(name = "{index} => Reading JavaDoc warnings from file \"{0}\"") |
| 584 | + @ValueSource(strings = {"javadoc.txt", "emptyFile.txt"}) |
| 585 | + @org.junitpioneer.jupiter.Issue("JENKINS-75344") |
| 586 | + void shouldReportResultWithDifferentIdNameAndIconInStep(final String fileName) { |
| 587 | + WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix(fileName); |
586 | 588 |
|
587 | 589 | job.setDefinition(asStage(
|
588 | 590 | "recordIssues id: 'custom-id', name: 'custom-name', icon: 'custom-icon', "
|
589 | 591 | + "tool: javaDoc(pattern:'**/*issues.txt', reportEncoding:'UTF-8')"));
|
590 | 592 |
|
591 | 593 | var action = getResultAction(buildWithResult(job, Result.SUCCESS));
|
| 594 | + assertThat(action.getUrlName()).isEqualTo("custom-id"); |
592 | 595 | assertThat(action.getId()).isEqualTo("custom-id");
|
593 | 596 | assertThat(action.getDisplayName()).startsWith("custom-name");
|
594 | 597 | assertThat(action.getIconFileName()).isEqualTo("custom-icon");
|
595 | 598 | }
|
596 | 599 |
|
597 |
| - @Test |
598 |
| - void shouldReportResultWithDifferentIdNameAndIconInTool() { |
599 |
| - WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix("emptyFile.txt"); |
| 600 | + @ParameterizedTest(name = "{index} => Reading JavaDoc warnings from file \"{0}\"") |
| 601 | + @ValueSource(strings = {"javadoc.txt", "emptyFile.txt"}) |
| 602 | + @org.junitpioneer.jupiter.Issue("JENKINS-75344") |
| 603 | + void shouldReportResultWithDifferentIdNameAndIconInTool(final String fileName) { |
| 604 | + WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix(fileName); |
600 | 605 |
|
601 | 606 | job.setDefinition(asStage(
|
602 | 607 | "recordIssues tool: javaDoc(pattern:'**/*issues.txt', reportEncoding:'UTF-8',"
|
603 | 608 | + "id: 'custom-id', name: 'custom-name', icon: 'custom-icon')"));
|
604 | 609 |
|
605 | 610 | var action = getResultAction(buildWithResult(job, Result.SUCCESS));
|
| 611 | + assertThat(action.getUrlName()).isEqualTo("custom-id"); |
| 612 | + assertThat(action.getId()).isEqualTo("custom-id"); |
| 613 | + assertThat(action.getDisplayName()).startsWith("custom-name"); |
| 614 | + assertThat(action.getIconFileName()).isEqualTo("custom-icon"); |
| 615 | + } |
| 616 | + |
| 617 | + @ParameterizedTest(name = "{index} => Reading JavaDoc warnings from file \"{0}\"") |
| 618 | + @ValueSource(strings = {"javadoc.txt", "emptyFile.txt"}) |
| 619 | + @org.junitpioneer.jupiter.Issue("JENKINS-75391") |
| 620 | + void shouldShowWarningWhenUsingIdForToolAndRecorder(final String fileName) { |
| 621 | + WorkflowJob job = createPipelineWithWorkspaceFilesWithSuffix(fileName); |
| 622 | + |
| 623 | + job.setDefinition(asStage( |
| 624 | + "recordIssues id: 'custom-id', name: 'custom-name', icon: 'custom-icon', " |
| 625 | + + "tool: javaDoc(pattern:'**/*issues.txt', reportEncoding:'UTF-8'," |
| 626 | + + "id: 'custom-id', name: 'custom-name', icon: 'custom-icon')")); |
| 627 | + |
| 628 | + var action = getResultAction(buildWithResult(job, Result.SUCCESS)); |
| 629 | + assertThat(action.getUrlName()).isEqualTo("custom-id"); |
606 | 630 | assertThat(action.getId()).isEqualTo("custom-id");
|
607 | 631 | assertThat(action.getDisplayName()).startsWith("custom-name");
|
608 | 632 | assertThat(action.getIconFileName()).isEqualTo("custom-icon");
|
| 633 | + |
| 634 | + assertThat(getConsoleLog(action.getOwner())) |
| 635 | + .contains("Do not set id, name, or icon for both the tool and the recorder"); |
609 | 636 | }
|
610 | 637 |
|
611 | 638 | /**
|
612 | 639 | * Runs the all Java parsers on three output files: the build should report issues of all tools. The results should
|
613 |
| - * be aggregated into a new action with the specified ID. Since no name is given the default name is used. |
| 640 | + * be aggregated into a new action with the specified ID. Since no name is given, the default name is used. |
614 | 641 | */
|
615 | 642 | @Test
|
616 | 643 | void shouldProvideADefaultNameIfNoOneIsGiven() {
|
@@ -926,7 +953,7 @@ void shouldLogWarningIfNameIsSetWhenNotAggregating() {
|
926 | 953 | assertThat(ids).containsExactly("groovy-1", "groovy-2");
|
927 | 954 |
|
928 | 955 | assertThat(getConsoleLog(build))
|
929 |
| - .contains("Do not set id, name, or icon for both the tool and the recorder"); |
| 956 | + .contains("Do not set id, name, or icon of recorder when multiple tools are defined"); |
930 | 957 | }
|
931 | 958 |
|
932 | 959 | /**
|
|
0 commit comments