From f7c6ae48e0703321ed7bdebbd498d259f7fb2980 Mon Sep 17 00:00:00 2001
From: strangelookingnerd
<49242855+strangelookingnerd@users.noreply.github.com>
Date: Mon, 10 Nov 2025 08:41:47 +0100
Subject: [PATCH 1/2] Migrate tests to JUnit Jupiter
* Migrate annotations and imports
* Migrate assertions
* Remove public visibility for test classes and methods
* Minor code cleanup
* Ban JUnit4 imports
---
pom.xml | 1 +
.../armorcode/ArmorCodeGlobalConfigTest.java | 29 ++--
.../armorcode/ArmorCodeJobDiscoveryTest.java | 129 ++++++++++--------
.../ArmorCodeReleaseGateBuilderTest.java | 54 ++++----
4 files changed, 119 insertions(+), 94 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0bbdac5..1ac860b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,6 +38,7 @@
A Jenkins build step that polls ArmorCode's build validation endpoint to enforce release gates. It can operate in either "warn" mode (marking the build as UNSTABLE if validation fails) or "block" mode (failing the build).
true
false
+ false
false
diff --git a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeGlobalConfigTest.java b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeGlobalConfigTest.java
index a03f39b..c668f7d 100644
--- a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeGlobalConfigTest.java
+++ b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeGlobalConfigTest.java
@@ -1,26 +1,33 @@
package io.jenkins.plugins.armorcode;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import hudson.util.FormValidation;
import io.jenkins.plugins.armorcode.config.ArmorCodeGlobalConfig;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
/**
* Test cases for ArmorCode global configuration.
*/
-public class ArmorCodeGlobalConfigTest {
+@WithJenkins
+class ArmorCodeGlobalConfigTest {
- @Rule
- public JenkinsRule jenkins = new JenkinsRule();
+ private JenkinsRule j;
+
+ @BeforeEach
+ void beforeEach(JenkinsRule rule) {
+ j = rule;
+ }
/**
* Test that global configuration can be saved and loaded correctly.
*/
@Test
- public void testGlobalConfigSaveAndLoad() {
+ void testGlobalConfigSaveAndLoad() {
// Get the configuration
ArmorCodeGlobalConfig config = ArmorCodeGlobalConfig.get();
@@ -36,16 +43,16 @@ public void testGlobalConfigSaveAndLoad() {
ArmorCodeGlobalConfig reloaded = ArmorCodeGlobalConfig.get();
// Verify values are preserved
- assertEquals("Base URL should be preserved", "http://localhost:3000/test", reloaded.getBaseUrl());
- assertFalse("Monitor builds setting should be preserved", reloaded.isMonitorBuilds());
- assertEquals("Job filter should be preserved", "prod.*,!test.*", reloaded.getJobFilter());
+ assertEquals("http://localhost:3000/test", reloaded.getBaseUrl(), "Base URL should be preserved");
+ assertFalse(reloaded.isMonitorBuilds(), "Monitor builds setting should be preserved");
+ assertEquals("prod.*,!test.*", reloaded.getJobFilter(), "Job filter should be preserved");
}
/**
* Test URL validation logic.
*/
@Test
- public void testUrlValidation() {
+ void testUrlValidation() {
ArmorCodeGlobalConfig config = ArmorCodeGlobalConfig.get();
// Empty URL
diff --git a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeJobDiscoveryTest.java b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeJobDiscoveryTest.java
index c19b417..ef59857 100644
--- a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeJobDiscoveryTest.java
+++ b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeJobDiscoveryTest.java
@@ -1,8 +1,6 @@
package io.jenkins.plugins.armorcode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
@@ -18,23 +16,25 @@
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-public class ArmorCodeJobDiscoveryTest {
-
- @Rule
- public JenkinsRule jenkins = new JenkinsRule();
+@WithJenkins
+class ArmorCodeJobDiscoveryTest {
private ArmorCodeJobDiscovery discovery;
private Method shouldMonitorJobMethod;
private Method isUsingArmorCodePluginMethod;
private Method collectJobsDataMethod;
- @Before
- public void setUp() throws Exception {
+ private JenkinsRule j;
+
+ @BeforeEach
+ void beforeEach(JenkinsRule rule) throws Exception {
+ j = rule;
+
discovery = new ArmorCodeJobDiscovery();
shouldMonitorJobMethod = ArmorCodeJobDiscovery.class.getDeclaredMethod(
"shouldMonitorJob", String.class, String.class, String.class);
@@ -50,52 +50,61 @@ public void setUp() throws Exception {
}
@Test
- public void testShouldMonitorJob() throws Exception {
+ void testShouldMonitorJob() throws Exception {
// Test case 1: No patterns, should include all
- assertTrue("Should include with no patterns", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "any-job", "", ""));
+ assertTrue(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "any-job", "", ""),
+ "Should include with no patterns");
// Test case 2: Include pattern matches
- assertTrue("Should include when matching include pattern", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "prod-job-1", "prod-.*", ""));
+ assertTrue(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "prod-job-1", "prod-.*", ""),
+ "Should include when matching include pattern");
// Test case 3: Include pattern does not match
- assertFalse("Should exclude when not matching include pattern", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "dev-job-1", "prod-.*", ""));
+ assertFalse(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "dev-job-1", "prod-.*", ""),
+ "Should exclude when not matching include pattern");
// Test case 4: Exclude pattern matches
- assertFalse("Should exclude when matching exclude pattern", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "test-job-1", "", "test-.*"));
+ assertFalse(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "test-job-1", "", "test-.*"),
+ "Should exclude when matching exclude pattern");
// Test case 5: Both include and exclude patterns match (exclude takes precedence)
- assertFalse("Should exclude when both patterns match", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "prod-test-job", "prod-.*", ".*-test-.*"));
+ assertFalse(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "prod-test-job", "prod-.*", ".*-test-.*"),
+ "Should exclude when both patterns match");
// Test case 6: Include all, exclude some
- assertTrue("Should include if not matching exclude", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "prod-job-1", "", "test-.*"));
- assertFalse("Should exclude if matching exclude", (boolean)
- shouldMonitorJobMethod.invoke(discovery, "test-job-1", "", "test-.*"));
+ assertTrue(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "prod-job-1", "", "test-.*"),
+ "Should include if not matching exclude");
+ assertFalse(
+ (boolean) shouldMonitorJobMethod.invoke(discovery, "test-job-1", "", "test-.*"),
+ "Should exclude if matching exclude");
}
@Test
- public void testIsUsingArmorCodePlugin_Freestyle() throws Exception {
+ void testIsUsingArmorCodePlugin_Freestyle() throws Exception {
// Create a freestyle project with the ArmorCode builder
- FreeStyleProject projectWithPlugin = jenkins.createFreeStyleProject("freestyle-with-plugin");
+ FreeStyleProject projectWithPlugin = j.createFreeStyleProject("freestyle-with-plugin");
projectWithPlugin.getBuildersList().add(new ArmorCodeReleaseGateBuilder("1", "1", "1"));
// Create a freestyle project without the ArmorCode builder
- FreeStyleProject projectWithoutPlugin = jenkins.createFreeStyleProject("freestyle-without-plugin");
+ FreeStyleProject projectWithoutPlugin = j.createFreeStyleProject("freestyle-without-plugin");
// Test
- assertTrue("Should detect plugin in Freestyle project with builder", (boolean)
- isUsingArmorCodePluginMethod.invoke(discovery, projectWithPlugin));
- assertFalse("Should not detect plugin in Freestyle project without builder", (boolean)
- isUsingArmorCodePluginMethod.invoke(discovery, projectWithoutPlugin));
+ assertTrue(
+ (boolean) isUsingArmorCodePluginMethod.invoke(discovery, projectWithPlugin),
+ "Should detect plugin in Freestyle project with builder");
+ assertFalse(
+ (boolean) isUsingArmorCodePluginMethod.invoke(discovery, projectWithoutPlugin),
+ "Should not detect plugin in Freestyle project without builder");
}
@Test
- public void testIsUsingArmorCodePlugin_Pipeline() throws Exception {
+ void testIsUsingArmorCodePlugin_Pipeline() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -105,23 +114,25 @@ public void testIsUsingArmorCodePlugin_Pipeline() throws Exception {
// Create a pipeline project with the ArmorCode step
// Don't run the build - just check if the config XML contains the step
- WorkflowJob pipelineWithPlugin = jenkins.createProject(WorkflowJob.class, "pipeline-with-plugin");
+ WorkflowJob pipelineWithPlugin = j.createProject(WorkflowJob.class, "pipeline-with-plugin");
pipelineWithPlugin.setDefinition(new CpsFlowDefinition(
"node { armorcodeReleaseGate(product: '1', subProducts: ['1'], env: '1') }", true));
// Create a pipeline project without the ArmorCode step
- WorkflowJob pipelineWithoutPlugin = jenkins.createProject(WorkflowJob.class, "pipeline-without-plugin");
+ WorkflowJob pipelineWithoutPlugin = j.createProject(WorkflowJob.class, "pipeline-without-plugin");
pipelineWithoutPlugin.setDefinition(new CpsFlowDefinition("node { echo 'hello' }", true));
// Test
- assertTrue("Should detect plugin in Pipeline project with step", (boolean)
- isUsingArmorCodePluginMethod.invoke(discovery, pipelineWithPlugin));
- assertFalse("Should not detect plugin in Pipeline project without step", (boolean)
- isUsingArmorCodePluginMethod.invoke(discovery, pipelineWithoutPlugin));
+ assertTrue(
+ (boolean) isUsingArmorCodePluginMethod.invoke(discovery, pipelineWithPlugin),
+ "Should detect plugin in Pipeline project with step");
+ assertFalse(
+ (boolean) isUsingArmorCodePluginMethod.invoke(discovery, pipelineWithoutPlugin),
+ "Should not detect plugin in Pipeline project without step");
}
@Test
- public void testCollectJobsData() throws Exception {
+ void testCollectJobsData() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -137,32 +148,32 @@ public void testCollectJobsData() throws Exception {
// Create jobs
// 1. Should be included (matches include, not exclude, has plugin)
- FreeStyleProject job1 = jenkins.createFreeStyleProject("prod-job-1");
+ FreeStyleProject job1 = j.createFreeStyleProject("prod-job-1");
ArmorCodeReleaseGateBuilderTest.MockArmorCodeReleaseGateBuilder mockBuilder =
new ArmorCodeReleaseGateBuilderTest.MockArmorCodeReleaseGateBuilder("1", "1", "1");
mockBuilder.setMockResponse("{\"status\":\"SUCCESS\"}");
job1.getBuildersList().add(mockBuilder);
// 2. Should be excluded (matches exclude)
- FreeStyleProject job2 = jenkins.createFreeStyleProject("prod-job-ignore");
+ FreeStyleProject job2 = j.createFreeStyleProject("prod-job-ignore");
job2.getBuildersList().add(new ArmorCodeReleaseGateBuilder("1", "1", "1"));
// 3. Should be excluded (does not match include)
- FreeStyleProject job3 = jenkins.createFreeStyleProject("dev-job-1");
+ FreeStyleProject job3 = j.createFreeStyleProject("dev-job-1");
job3.getBuildersList().add(new ArmorCodeReleaseGateBuilder("1", "1", "1"));
// 4. Should be included (matches include, no plugin)
- FreeStyleProject job4 = jenkins.createFreeStyleProject("prod-job-2");
+ FreeStyleProject job4 = j.createFreeStyleProject("prod-job-2");
// Run a build for job1 to have build data
- jenkins.buildAndAssertSuccess(job1);
+ j.buildAndAssertSuccess(job1);
// Call collectJobsData
TaskListener listener = new StreamTaskListener(System.out, null);
List jobsData = (List) collectJobsDataMethod.invoke(discovery, config, listener);
// Assertions
- assertEquals("Should collect 2 jobs", 2, jobsData.size());
+ assertEquals(2, jobsData.size(), "Should collect 2 jobs");
boolean foundJob1 = false;
boolean foundJob4 = false;
@@ -171,21 +182,21 @@ public void testCollectJobsData() throws Exception {
String jobName = jobData.getString("jobName");
if (jobName.equals("prod-job-1")) {
foundJob1 = true;
- assertTrue("Job 1 should be marked as mapped", jobData.getBoolean("jobMapped"));
- assertEquals("Job 1 should have build number 1", "1", jobData.getString("buildNumber"));
+ assertTrue(jobData.getBoolean("jobMapped"), "Job 1 should be marked as mapped");
+ assertEquals("1", jobData.getString("buildNumber"), "Job 1 should have build number 1");
} else if (jobName.equals("prod-job-2")) {
foundJob4 = true;
- assertFalse("Job 4 should not be marked as mapped", jobData.getBoolean("jobMapped"));
- assertEquals("Job 4 should have build number 0", "0", jobData.getString("buildNumber"));
+ assertFalse(jobData.getBoolean("jobMapped"), "Job 4 should not be marked as mapped");
+ assertEquals("0", jobData.getString("buildNumber"), "Job 4 should have build number 0");
}
}
- assertTrue("Job 'prod-job-1' should be in the collected data", foundJob1);
- assertTrue("Job 'prod-job-2' should be in the collected data", foundJob4);
+ assertTrue(foundJob1, "Job 'prod-job-1' should be in the collected data");
+ assertTrue(foundJob4, "Job 'prod-job-2' should be in the collected data");
}
@Test
- public void testGetRecurrencePeriod() throws Exception {
+ void testGetRecurrencePeriod() {
ArmorCodeGlobalConfig config = ArmorCodeGlobalConfig.get();
// getRecurrencePeriod() is only called once at startup by AsyncPeriodicWork
@@ -197,17 +208,17 @@ public void testGetRecurrencePeriod() throws Exception {
config.setMonitorBuilds(false);
config.save();
assertEquals(
- "Should always be 1 minute (called once at startup)",
TimeUnit.MINUTES.toMillis(1),
- discovery.getRecurrencePeriod());
+ discovery.getRecurrencePeriod(),
+ "Should always be 1 minute (called once at startup)");
// Test case 2: Monitoring enabled - should return 1 minute
// (execute() method checks cron expression for actual execution)
config.setMonitorBuilds(true);
config.save();
assertEquals(
- "Should always be 1 minute (called once at startup)",
TimeUnit.MINUTES.toMillis(1),
- discovery.getRecurrencePeriod());
+ discovery.getRecurrencePeriod(),
+ "Should always be 1 minute (called once at startup)");
}
}
diff --git a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
index c21b27a..a4c4ba8 100644
--- a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
+++ b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
@@ -1,7 +1,7 @@
package io.jenkins.plugins.armorcode;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
@@ -12,14 +12,13 @@
import hudson.model.TaskListener;
import hudson.util.Secret;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.jvnet.hudson.test.JenkinsRule;
+import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
-public class ArmorCodeReleaseGateBuilderTest {
-
- @Rule
- public JenkinsRule jenkins = new JenkinsRule();
+@WithJenkins
+class ArmorCodeReleaseGateBuilderTest {
public static class MockArmorCodeReleaseGateBuilder extends ArmorCodeReleaseGateBuilder {
@@ -64,8 +63,15 @@ public String getDisplayName() {
}
}
+ private JenkinsRule j;
+
+ @BeforeEach
+ void beforeEach(JenkinsRule rule) {
+ j = rule;
+ }
+
@Test
- public void testBlockModeBehavior() throws Exception {
+ void testBlockModeBehavior() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -74,7 +80,7 @@ public void testBlockModeBehavior() throws Exception {
SystemCredentialsProvider.getInstance().save();
// Create a freestyle project
- FreeStyleProject project = jenkins.createFreeStyleProject("test-block-mode");
+ FreeStyleProject project = j.createFreeStyleProject("test-block-mode");
// Create the builder with block mode
MockArmorCodeReleaseGateBuilder builder = new MockArmorCodeReleaseGateBuilder("123", "456", "Production");
@@ -88,11 +94,11 @@ public void testBlockModeBehavior() throws Exception {
FreeStyleBuild build = project.scheduleBuild2(0).get();
// Verify the build was marked as failed
- assertEquals("Build should be failed in block mode", Result.FAILURE, build.getResult());
+ assertEquals(Result.FAILURE, build.getResult(), "Build should be failed in block mode");
}
@Test
- public void testWarnModeBehavior() throws Exception {
+ void testWarnModeBehavior() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -101,7 +107,7 @@ public void testWarnModeBehavior() throws Exception {
SystemCredentialsProvider.getInstance().save();
// Create a freestyle project
- FreeStyleProject project = jenkins.createFreeStyleProject("test-warn-mode");
+ FreeStyleProject project = j.createFreeStyleProject("test-warn-mode");
// Create the builder with warn mode
MockArmorCodeReleaseGateBuilder builder = new MockArmorCodeReleaseGateBuilder("123", "456", "Production");
@@ -121,15 +127,15 @@ public void testWarnModeBehavior() throws Exception {
FreeStyleBuild build = project.scheduleBuild2(0).get();
// Verify the build was marked as unstable
- assertEquals("Build should be unstable in warn mode", Result.UNSTABLE, build.getResult());
+ assertEquals(Result.UNSTABLE, build.getResult(), "Build should be unstable in warn mode");
// Verify the build continued (shell command ran)
String log = build.getLog();
- assertTrue("Build should continue in warn mode", log.contains("Should reach here in warn mode"));
+ assertTrue(log.contains("Should reach here in warn mode"), "Build should continue in warn mode");
}
@Test
- public void testSuccessModeBehavior() throws Exception {
+ void testSuccessModeBehavior() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -138,7 +144,7 @@ public void testSuccessModeBehavior() throws Exception {
SystemCredentialsProvider.getInstance().save();
// Create a freestyle project
- FreeStyleProject project = jenkins.createFreeStyleProject("test-success-mode");
+ FreeStyleProject project = j.createFreeStyleProject("test-success-mode");
// Create the builder
MockArmorCodeReleaseGateBuilder builder = new MockArmorCodeReleaseGateBuilder("123", "456", "Production");
@@ -151,11 +157,11 @@ public void testSuccessModeBehavior() throws Exception {
FreeStyleBuild build = project.scheduleBuild2(0).get();
// Verify the build was marked as success
- assertEquals("Build should be successful", Result.SUCCESS, build.getResult());
+ assertEquals(Result.SUCCESS, build.getResult(), "Build should be successful");
}
@Test
- public void testHoldModeBehavior() throws Exception {
+ void testHoldModeBehavior() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -164,7 +170,7 @@ public void testHoldModeBehavior() throws Exception {
SystemCredentialsProvider.getInstance().save();
// Create a freestyle project
- FreeStyleProject project = jenkins.createFreeStyleProject("test-hold-mode");
+ FreeStyleProject project = j.createFreeStyleProject("test-hold-mode");
// Create the builder
MockArmorCodeReleaseGateBuilder builder = new MockArmorCodeReleaseGateBuilder("123", "456", "Production");
@@ -180,14 +186,14 @@ public void testHoldModeBehavior() throws Exception {
FreeStyleBuild build = project.scheduleBuild2(0).get();
// Verify the build was marked as failed
- assertEquals("Build should fail after exhausting retries on HOLD", Result.FAILURE, build.getResult());
+ assertEquals(Result.FAILURE, build.getResult(), "Build should fail after exhausting retries on HOLD");
String log = build.getLog();
assertTrue(log.contains("SLA is on HOLD. Sleeping 1s..."));
assertTrue(log.contains("ArmorCode check did not pass after 2 retries (last status was HOLD)."));
}
@Test
- public void testInvalidResponseFailure() throws Exception {
+ void testInvalidResponseFailure() throws Exception {
// Create a credential
String tokenValue = "my-secret-token";
StringCredentialsImpl credential = new StringCredentialsImpl(
@@ -196,7 +202,7 @@ public void testInvalidResponseFailure() throws Exception {
SystemCredentialsProvider.getInstance().save();
// Create a freestyle project
- FreeStyleProject project = jenkins.createFreeStyleProject("test-invalid-response");
+ FreeStyleProject project = j.createFreeStyleProject("test-invalid-response");
// Create the builder
MockArmorCodeReleaseGateBuilder builder = new MockArmorCodeReleaseGateBuilder("123", "456", "Production");
@@ -211,7 +217,7 @@ public void testInvalidResponseFailure() throws Exception {
FreeStyleBuild build = project.scheduleBuild2(0).get();
// Verify the build was marked as failed
- assertEquals("Build should fail with invalid JSON response", Result.FAILURE, build.getResult());
+ assertEquals(Result.FAILURE, build.getResult(), "Build should fail with invalid JSON response");
String log = build.getLog();
assertTrue(log.contains("ArmorCode request failed:"));
assertTrue(log.contains("ArmorCode request error after maximum retries."));
From 570896f96bf2637b4062f46fdd578cc8a6ded11b Mon Sep 17 00:00:00 2001
From: strangelookingnerd
<49242855+strangelookingnerd@users.noreply.github.com>
Date: Mon, 17 Nov 2025 09:46:56 +0100
Subject: [PATCH 2/2] Fix bad merge
---
.../plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
index f59bb2e..a1aee06 100644
--- a/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
+++ b/src/test/java/io/jenkins/plugins/armorcode/ArmorCodeReleaseGateBuilderTest.java
@@ -70,13 +70,6 @@ public String getDisplayName() {
}
}
- private JenkinsRule j;
-
- @BeforeEach
- void beforeEach(JenkinsRule rule) {
- j = rule;
- }
-
@Test
void testBlockModeBehavior() throws Exception {
// Create a credential