Fixed build error issues.
@@ -6,7 +6,6 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;
-import org.eclipse.collections.api.list.ImmutableList;
import org.junit.Test;
import org.jvnet.hudson.test.JenkinsRule.WebClient;
import org.jvnet.hudson.test.recipes.WithTimeout;
@@ -243,6 +242,54 @@ public class IssuesRecorderITest extends IntegrationTest {
}
}
+ /**
+ * Schedules a new build for the specified job and checks the console log.
+ *
+ * @param job
+ * the job to schedule
+ * @param status
+ * the expected result of both tools for the build
+ * @param log
+ * the log string asserted to be in console
+ *
+ * @return the created {@link FreeStyleBuild}
+ */
+ @SuppressWarnings({"illegalcatch", "OverlyBroadCatchBlock"})
+ private FreeStyleBuild scheduleBuildAndAssertLog(final FreeStyleProject job, final Result status, final String log) {
+ try {
+ FreeStyleBuild build = j.assertBuildStatus(status, job.scheduleBuild2(0));
+ j.assertLogContains(log, build);
+ return build;
+ }
+ catch (Exception e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ /**
+ * Creates a {@link List<AnalysisResult>} of the analysis results of {@link FreeStyleBuild}.
+ *
+ * @param build
+ * the FreeStyleBuild
+ *
+ * @return the created {@link List<ResultAction>}
+ */
+ @SuppressWarnings({"illegalcatch", "OverlyBroadCatchBlock"})
+ private List<AnalysisResult> getAssertStatusForBothTools(final FreeStyleBuild build) {
+ try {
+ List<ResultAction> actions = build.getActions(ResultAction.class);
+
+ List<AnalysisResult> results = new ArrayList<>();
+ for (ResultAction elements : actions) {
+ results.add(elements.getResult());
+ }
+ return results;
+ }
+ catch (Exception e) {
+ throw new AssertionError(e);
+ }
+ }
+
/**
* Runs the CheckStyle and PMD tools for two corresponding files which contain at least 6 respectively 4 issues: the
* build should report 6 and 4 issues.
@@ -303,10 +350,11 @@ public class IssuesRecorderITest extends IntegrationTest {
enableWarningsAggregation(project, false, "**/checkstyle2-issues.txt", new CheckStyle(),
"**/checkstyle3-issues.txt", new CheckStyle());
- List<AnalysisResult> results = scheduleBuildAndAssertStatusForBothTools(project, Result.FAILURE);
+ FreeStyleBuild build = scheduleBuildAndAssertLog(project, Result.FAILURE,"ID checkstyle is already used by another action: io.jenkins.plugins.analysis.core.views.ResultAction for CheckStyle");
+
+ List<AnalysisResult> results = getAssertStatusForBothTools(build);
assertThat(results).hasSize(1);
- assertThat(results.contains("java.lang.IllegalStateException: ID checkstyle is already used by another action: io.jenkins.plugins.analysis.core.views.ResultAction for CheckStyle"));
for (AnalysisResult element : results) {
assertThat(element).hasId("checkstyle");
