Skip to content

Commit 2645ecd

Browse files
saurabh-ossclaude
andcommitted
fix: switch to JUnit Jupiter, remove unused mockito, fix SpotBugs errors
- Remove mockito-core (unused) and workflow-step-api test classifier - Add junit-jupiter (BOM-managed) for JUnit 5 - Migrate ForgeAIPluginTest from JUnit 4 to JUnit Jupiter - Fix RCN_REDUNDANT_NULLCHECK in healthCheck() across all providers - Suppress VA_FORMAT_STRING_USES_NEWLINE in ForgeAIReportGenerator (HTML output intentionally uses \n, not platform-dependent %n) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 833e2a3 commit 2645ecd

5 files changed

Lines changed: 19 additions & 21 deletions

File tree

pom.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,8 @@
104104

105105
<!-- Test Dependencies -->
106106
<dependency>
107-
<groupId>org.jenkins-ci.plugins.workflow</groupId>
108-
<artifactId>workflow-step-api</artifactId>
109-
<classifier>tests</classifier>
110-
<scope>test</scope>
111-
</dependency>
112-
<dependency>
113-
<groupId>org.mockito</groupId>
114-
<artifactId>mockito-core</artifactId>
115-
<version>5.11.0</version>
107+
<groupId>org.junit.jupiter</groupId>
108+
<artifactId>junit-jupiter</artifactId>
116109
<scope>test</scope>
117110
</dependency>
118111
</dependencies>

src/main/java/io/forgeai/jenkins/llm/AnthropicProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public String complete(String systemPrompt, String userPrompt, int maxTokens) th
8686
@Override
8787
public boolean healthCheck() {
8888
try {
89-
return complete("You are a health-check bot.", "Reply OK", 10) != null;
89+
complete("You are a health-check bot.", "Reply OK", 10);
90+
return true;
9091
} catch (LLMException e) {
9192
return false;
9293
}

src/main/java/io/forgeai/jenkins/llm/OpenAICompatibleProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public String complete(String systemPrompt, String userPrompt, int maxTokens) th
8787
@Override
8888
public boolean healthCheck() {
8989
try {
90-
return complete("You are a health-check bot.", "Reply OK", 10) != null;
90+
complete("You are a health-check bot.", "Reply OK", 10);
91+
return true;
9192
} catch (LLMException e) {
9293
return false;
9394
}

src/main/java/io/forgeai/jenkins/reports/ForgeAIReportGenerator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.forgeai.jenkins.reports;
22

3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34
import java.text.SimpleDateFormat;
45
import java.util.Date;
56
import java.util.List;
@@ -12,6 +13,8 @@ public final class ForgeAIReportGenerator {
1213

1314
private ForgeAIReportGenerator() {}
1415

16+
@SuppressFBWarnings(value = "VA_FORMAT_STRING_USES_NEWLINE",
17+
justification = "HTML output intentionally uses \\n, not platform-dependent %n")
1518
public static String generateHtml(List<AnalysisResult> results, String projectName,
1619
String buildNumber) {
1720
StringBuilder html = new StringBuilder();

src/test/java/io/forgeai/jenkins/ForgeAIPluginTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
import io.forgeai.jenkins.analyzers.ResultParser;
44
import io.forgeai.jenkins.reports.AnalysisResult;
5-
import org.junit.Test;
5+
import org.junit.jupiter.api.Test;
66

77
import java.io.PrintStream;
88

9-
import static org.junit.Assert.*;
9+
import static org.junit.jupiter.api.Assertions.*;
1010

11-
public class ForgeAIPluginTest {
11+
class ForgeAIPluginTest {
1212

1313
private final PrintStream log = System.out;
1414

1515
@Test
16-
public void testResultParser_validJson() {
16+
void testResultParser_validJson() {
1717
String json = """
1818
{
1919
"score": 7,
@@ -40,7 +40,7 @@ public void testResultParser_validJson() {
4040
}
4141

4242
@Test
43-
public void testResultParser_markdownWrapped() {
43+
void testResultParser_markdownWrapped() {
4444
String json = """
4545
```json
4646
{"score":9,"severity":"LOW","summary":"All good.","findings":[]}
@@ -52,15 +52,15 @@ public void testResultParser_markdownWrapped() {
5252
}
5353

5454
@Test
55-
public void testResultParser_malformedJson() {
55+
void testResultParser_malformedJson() {
5656
String garbage = "This is not JSON at all.";
5757
AnalysisResult result = ResultParser.parse(garbage, "test", "Test", log);
58-
assertEquals(5, result.getScore()); // default fallback
58+
assertEquals(5, result.getScore());
5959
assertNotNull(result.getRawMarkdown());
6060
}
6161

6262
@Test
63-
public void testResultParser_extraTextBeforeJson() {
63+
void testResultParser_extraTextBeforeJson() {
6464
String response = "Sure! Here is the analysis:\n{\"score\":4,\"severity\":\"HIGH\"," +
6565
"\"summary\":\"Issues found.\",\"findings\":[]}";
6666
AnalysisResult result = ResultParser.parse(response, "vuln", "Vuln", log);
@@ -69,7 +69,7 @@ public void testResultParser_extraTextBeforeJson() {
6969
}
7070

7171
@Test
72-
public void testAnalysisResult_countBySeverity() {
72+
void testAnalysisResult_countBySeverity() {
7373
AnalysisResult r = new AnalysisResult("test", "Test");
7474
r.addFinding(new AnalysisResult.Finding("A", "CRITICAL", "desc"));
7575
r.addFinding(new AnalysisResult.Finding("B", "CRITICAL", "desc"));
@@ -82,7 +82,7 @@ public void testAnalysisResult_countBySeverity() {
8282
}
8383

8484
@Test
85-
public void testAnalysisResult_scoreClamp() {
85+
void testAnalysisResult_scoreClamp() {
8686
AnalysisResult r = new AnalysisResult("test", "Test");
8787
r.setScore(15);
8888
assertEquals(10, r.getScore());

0 commit comments

Comments
 (0)