From 12db0eba5f039d2665d0a20d96e3666b017d92aa Mon Sep 17 00:00:00 2001 From: Edgars Batna Date: Tue, 23 Jul 2024 12:03:19 +0200 Subject: [PATCH] Prepare for API change in JUnit. See https://github.com/jenkinsci/junit-plugin/pull/625 --- .../AttachmentPublisherPipelineTest.java | 3 ++- .../junitattachments/AttachmentPublisherTest.java | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherPipelineTest.java b/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherPipelineTest.java index a3dd37c..7d1e7e3 100644 --- a/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherPipelineTest.java +++ b/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherPipelineTest.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.net.URL; +import java.util.Collection; import java.util.Collections; import java.util.List; @@ -78,7 +79,7 @@ public void annotationDoesNotFailForPipeline() throws Exception { TestResultAction action = getTestResultActionForPipeline("workspace2.zip", "pipelineTest.groovy", Result.UNSTABLE); ClassResult cr = getClassResult(action, TEST_PACKAGE, "SignupTest"); - List caseResults = cr.getChildren(); + Collection caseResults = cr.getChildren(); assertEquals(3, caseResults.size()); CaseResult failingCase = cr.getCaseResult("A_003_Type_the_text__jenkins__into_the_field__username_"); diff --git a/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherTest.java b/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherTest.java index 6cde21a..5807735 100644 --- a/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherTest.java +++ b/src/test/java/hudson/plugins/junitattachments/AttachmentPublisherTest.java @@ -25,6 +25,7 @@ import hudson.util.DescribableList; import java.io.IOException; import java.io.Serializable; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.Rule; @@ -88,7 +89,7 @@ public void testAttachmentsShownForTestcases_SignupTest() throws Exception { TestResultAction action = getTestResultActionForBuild("workspace2.zip", Result.UNSTABLE); ClassResult classResult = getClassResult(action, "SignupTest"); - List cases = classResult.getChildren(); + List cases = new ArrayList<>(classResult.getChildren()); assertEquals(3, cases.size()); // Each test case should have the respective one attachment @@ -103,7 +104,7 @@ public void testAttachmentsShownForTestcases_SignupTest_WithRunnerPrefix() throw TestResultAction action = getTestResultActionForBuild("workspace3.zip", Result.UNSTABLE); ClassResult classResult = getClassResult(action, "SignupTest"); - List cases = classResult.getChildren(); + List cases = new ArrayList<>(classResult.getChildren()); assertEquals(3, cases.size()); // Each test case should have the respective one attachment @@ -127,7 +128,7 @@ public void testAttachmentsShownForTestcases_LoginTest() throws Exception { TestResultAction action = getTestResultActionForBuild("workspace2.zip", Result.UNSTABLE); ClassResult classResult = getClassResult(action, "LoginTest"); - List cases = classResult.getChildren(); + List cases = new ArrayList<>(classResult.getChildren()); assertEquals(4, cases.size()); // Each test case should have the respective one (or zero) attachments @@ -154,7 +155,7 @@ public void testAttachmentsShownForTestcases_MiscTest1() throws Exception { TestResultAction action = getTestResultActionForBuild("workspace2.zip", Result.UNSTABLE); ClassResult classResult = getClassResult(action, "MiscTest1"); - List cases = classResult.getChildren(); + List cases = new ArrayList<>(classResult.getChildren()); assertEquals(1, cases.size()); // Attachment should not be inherited from testsuite @@ -177,7 +178,7 @@ public void testAttachmentsShownForTestcases_MiscTest2() throws Exception { TestResultAction action = getTestResultActionForBuild("workspace2.zip", Result.UNSTABLE); ClassResult classResult = getClassResult(action, "MiscTest2"); - List cases = classResult.getChildren(); + List cases = new ArrayList<>(classResult.getChildren()); assertEquals(2, cases.size()); // Alphabetically first comes the "doNothing" test