You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2026/10/09 19:24:25 UTC
(juneau) branch juneau-release-manager updated: Use Shorts b() for Boolean.TRUE.equals and inline the S1192 string constants behind class-level suppressions; split TestReportEvents.collect into a Collector helper; CODE-CONVENTIONS now says always suppress S1192 (never extract), names the everyday Shorts idioms, and corrects the or() null-mapper note.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch juneau-release-manager
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/juneau-release-manager by this push:
new 0651591fef Use Shorts b() for Boolean.TRUE.equals and inline the S1192 string constants behind class-level suppressions; split TestReportEvents.collect into a Collector helper; CODE-CONVENTIONS now says always suppress S1192 (never extract), names the everyday Shorts idioms, and corrects the or() null-mapper note.
0651591fef is described below
commit 0651591fefd7d5bbf400d54a0ad26138450e42bf
Author: James Bognar <ja...@apache.org>
AuthorDate: Fri Oct 9 15:24:19 2026 -0400
Use Shorts b() for Boolean.TRUE.equals and inline the S1192 string constants behind class-level suppressions; split TestReportEvents.collect into a Collector helper; CODE-CONVENTIONS now says always suppress S1192 (never extract), names the everyday Shorts idioms, and corrects the or() null-mapper note.
Co-Authored-By: Claude Opus 5.5 (1M context) <no...@anthropic.com>
---
CODE-CONVENTIONS.md | 11 ++--
.../apache/juneau/releng/engine/ReleaseEngine.java | 20 +++---
.../juneau/releng/engine/TestReportEvents.java | 74 +++++++++++++--------
.../apache/juneau/releng/log/RunEventStore.java | 10 ++-
.../juneau/releng/nexus/NexusStagingClient.java | 4 +-
.../juneau/releng/release/GithubReleaseSource.java | 4 +-
.../org/apache/juneau/releng/rest/ReleaseRest.java | 3 +
.../juneau/releng/setup/SetupProbeService.java | 4 +-
.../juneau/releng/util/DefaultProcessRunner.java | 6 +-
.../releng/engine/ReleaseEngineRunViewTest.java | 75 +++++++++++-----------
.../juneau/releng/log/StepOutputSourcesTest.java | 34 +++++-----
11 files changed, 135 insertions(+), 110 deletions(-)
diff --git a/CODE-CONVENTIONS.md b/CODE-CONVENTIONS.md
index 34d2505789..def51cbce5 100644
--- a/CODE-CONVENTIONS.md
+++ b/CODE-CONVENTIONS.md
@@ -37,6 +37,8 @@ Each item: a one-line rule, then **Applied** or **N/A** (with rationale).
(`NexusMockRestHttpTest` wrapping a caught `Exception`, `SseLogServletTest` simulated broken-pipe
`IOException`, `RunStateBroadcasterTest` `"dead client"` subscriber) — constructors stay; `rex`/`ioex`
would not be clearer there.
+- **Always-suppress Sonar rules.** JRM uses the always-suppress table in `@juneau-code-conventions` (S1192, S3776, S6539, S6541, S110, S115, S9149). When one fires, suppress it; don't refactor to satisfy it. **`java:S1192`: inline and suppress, never extract.** Do not add `private static final String PROJECT = "project";`-style constants for duplicated literals. Keep the literal inline and suppress `java:S1192` once at class level, with a rationale (James 2026-10-09).
+- **Everyday `Shorts` idioms** — In new and touched code, use the Shorts forms from `@juneau-code-conventions` → "Shorts for everyday idioms" (`b(x)` for `Boolean.TRUE.equals(x)`, `eq`/`neq`, `ie`/`ine`, `ib`/`inb`, `sw`/`ew`/`co`, `lc`/`uc`/`tr`, `ein`/`nie`, `s`, `f`, `or`, `o`/`oo`, `u`, `cn`/`cns`, `rnn`) instead of the JDK spelling (James 2026-10-09).
- **Collection factories (`Shorts` `l`/`m`/`tl`/`los`/`cp`)** — **Applied** at real candidates only
(leftover pass 2026-09-13). Copy constructor → `tl` (`ReleaseListService`); empty insertion-ordered
map → `m()` (`MilestoneService`, `ReleaseListService`, `ReleaseRunRest` meta); known ≤10-pair map →
@@ -101,9 +103,9 @@ and re-swept 2026-09-13 (WORK-R0008 leftover pass):
- **First-non-null coalesce (`Shorts.or(...)`)** — **N/A (not a null-safe mapper).** Re-triaged
2026-09-13: ~12 `x == null ? null : f(x)` ternaries remain in `src/main` (`EmailService`,
`NexusStagingClient`, `MilestoneService`, `ReleaseRunRest`, `ReleaseEngine`, `DistPromoteStep`,
- `MavenSettingsCredentials`, `GithubReleaseSource`). Each is a null-safe mapper (`f(x)` is not
- independently null-safe). `or(x, f(x))` still evaluates `f(x)` when `x` is null and would change
- behavior; leave the ternary.
+ `MavenSettingsCredentials`, `GithubReleaseSource`). Each is a null-safe mapper, and Shorts has no helper for that.
+ `or()` returns its first non-null argument, so `or(x, f(x))` returns `x`, not `f(x)`. It also
+ evaluates `f(x)` when `x` is null. Leave the ternary.
- **Injectable wall-clock `Clock`** — **N/A (none found).** Reconfirmed 2026-09-13: no direct
`System.currentTimeMillis()` calls in `src/main`.
- **Size assertions (`assertSize`)** — **Applied** (leftover pass 2026-09-13). R0005 recorded N/A
@@ -208,13 +210,12 @@ trailing comment.
| `java:S110` (inheritance depth) | `RootRest` | Depth is imposed by the Juneau REST servlet base-class hierarchy; flattening isn't appropriate. Class-level. |
| `java:S6539` (Monster Class / too many deps) | `AppConfiguration` | A Spring `@Configuration` legitimately aggregates bean wiring; splitting fragments cohesive wiring. Juneau suppresses S6539 unconditionally. Class-level. |
| `java:S107` (too many params) | `ReleaseEngine` constructor | Constructor-injected collaborators; a parameter object would obscure the DI wiring. Suppress at the constructor only when a holder/record refactor would read worse than plain constructor injection (document the choice). |
-| `java:S1192` (duplicate literals) | — | Suppress at class level **only** when the repeated literal is a protocol-wire value, annotation attribute, or config key where a constant would obscure meaning. Ordinary duplicated strings → extract a constant instead (see below). |
+| `java:S1192` (duplicate literals) | — | **Always** suppress at class level; never extract a constant to satisfy it (James 2026-10-09, overriding the earlier "extract ordinary literals" rule). |
| `java:S115` (constant naming) | — | Suppress at **class** level (never on the field) for `UPPER_camelCase` constants or constants mirroring an external-protocol literal. |
| `unchecked` (parsed-JSON casts) | JSON parse sites | Assigning a raw `Json.DEFAULT.read(…, List.class/Map.class)` result to its known parameterized shape is an unchecked conversion; keep the multiline-form suppression with a rationale. |
**Fix, don't suppress (rules handled by real changes in this repo):**
-- `java:S1192` — extract a constant for ordinary duplicated string literals (not protocol/annotation/config keys). E.g. `EmailTemplate.DEV` (dev-list address), `DefaultProcessRunner.MSG_INTERRUPTED`/`MSG_ERROR`.
- `java:S125` — delete genuinely commented-out code; if it's explanatory prose that Sonar's recognizer misclassifies (e.g. a comment containing `Type.method()`), reword it so it isn't code-shaped rather than deleting the explanation.
- `java:S1845` — rename to remove a method/field name clash (prefer renaming the field): `CredentialSpec.name`→`id`, `StepResult.ok` field→`success` (keeping the `ok(…)`/`fail(…)` factory pair). Update all references + tests; keep behavior identical.
- `java:S1172` — remove unused parameters and simplify callers/tests.
diff --git a/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java b/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
index ae662c4546..e7479d3568 100644
--- a/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
+++ b/src/main/java/org/apache/juneau/releng/engine/ReleaseEngine.java
@@ -45,11 +45,11 @@ import org.apache.juneau.rest.server.views.RunViewSource;
/**
* Single-active-run orchestrator. One run advances at a time; state is persisted after every step.
*/
+@SuppressWarnings({
+ "java:S1192" // Step ids and failure messages read more clearly inline than as constants.
+})
public class ReleaseEngine {
- private static final String VOTE_GATE = "vote-gate";
- private static final String UNKNOWN_STEP = "Unknown step: ";
-
private final RunStateStore store;
private final StepRegistry registry;
private final ProcessRunner runner;
@@ -361,7 +361,7 @@ public class ReleaseEngine {
var rs = require(version);
var step = registry.byId(stepId);
if (step == null)
- return StepResult.fail(UNKNOWN_STEP + stepId);
+ return StepResult.fail("Unknown step: " + stepId);
var blocked = forwardApplyGuardMessage(rs, stepId);
if (blocked.isPresent())
return StepResult.fail(blocked.get());
@@ -383,7 +383,7 @@ public class ReleaseEngine {
if (result.success) {
ss.error = null; // a later success of the same step must not keep a leftover failure message
- if (stepId.equals(VOTE_GATE)) {
+ if (stepId.equals("vote-gate")) {
ss.status = StepStatus.AWAITING_VOTE;
rs.status = RunStatus.AWAITING_VOTE;
} else if (step.reviewGate()) {
@@ -398,11 +398,11 @@ public class ReleaseEngine {
// status to terminal so the forward-apply guard (and finalize-run's prerequisite check)
// treat it as satisfied. A rejected tally leaves vote-gate AWAITING_VOTE; that path forks
// to Drop-RC instead of advancing the linear pipeline.
- var gate = rs.step(VOTE_GATE);
+ var gate = rs.step("vote-gate");
if (gate != null) {
gate.status = StepStatus.SUCCEEDED;
gate.completedAt = ss.completedAt;
- events.end(version, VOTE_GATE, EndStatus.OK, elapsedMs(gate.startedAt, gate.completedAt));
+ events.end(version, "vote-gate", EndStatus.OK, elapsedMs(gate.startedAt, gate.completedAt));
}
}
if (stepId.equals("finalize-run")) {
@@ -466,7 +466,7 @@ public class ReleaseEngine {
var rs = require(version);
var step = registry.byId(stepId);
if (step == null)
- return StepResult.fail(UNKNOWN_STEP + stepId);
+ return StepResult.fail("Unknown step: " + stepId);
if (!step.skippable())
return StepResult.fail(stepId + " is not skippable.");
var ss = rs.step(stepId);
@@ -485,7 +485,7 @@ public class ReleaseEngine {
requireStep(stepId);
var ss = rs.step(stepId);
if (ss == null)
- return StepResult.fail(UNKNOWN_STEP + stepId);
+ return StepResult.fail("Unknown step: " + stepId);
if (ss.status != StepStatus.AWAITING_REVIEW)
return StepResult.fail(stepId + " is not awaiting review.");
ss.status = StepStatus.SUCCEEDED;
@@ -536,7 +536,7 @@ public class ReleaseEngine {
// A predecessor is satisfied when it's absent, terminal-success, or the still-open vote-gate that
// the tally step is specifically allowed to resolve — none of those block forward apply.
var satisfied = priorState == null || isTerminalSuccess(registry.byId(priorId), priorState.status)
- || (priorId.equals(VOTE_GATE) && stepId.equals("tally-vote-result")
+ || (priorId.equals("vote-gate") && stepId.equals("tally-vote-result")
&& priorState.status == StepStatus.AWAITING_VOTE);
if (satisfied)
continue;
diff --git a/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java b/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java
index 7ecbbeebe6..69e9a933a0 100644
--- a/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java
+++ b/src/main/java/org/apache/juneau/releng/engine/TestReportEvents.java
@@ -65,13 +65,7 @@ final class TestReportEvents {
static List<RunEvent> collect(Path root, Instant since, String stepId) {
if (root == null || ! Files.isDirectory(root))
return List.of();
- var limits = ReportLimits.DEFAULT;
- var cutoff = since.toEpochMilli() - CLOCK_SLACK_MS;
- var reader = new SurefireReportReader();
- var tests = new ArrayList<ReportTest>();
- var warnings = new ArrayList<String>();
- var found = new boolean[1];
- var capped = new boolean[1];
+ var c = new Collector(since.toEpochMilli() - CLOCK_SLACK_MS);
try {
Files.walkFileTree(root, Set.of(), MAX_DEPTH, new SimpleFileVisitor<>() {
@Override /* FileVisitor */
@@ -81,31 +75,57 @@ final class TestReportEvents {
return FileVisitResult.SKIP_SUBTREE;
if (! REPORT_DIRS.contains(name))
return FileVisitResult.CONTINUE;
- try (var files = Files.newDirectoryStream(dir, "TEST-*.xml")) {
- for (var f : files) {
- if (Files.getLastModifiedTime(f).toMillis() < cutoff)
- continue;
- found[0] = true;
- if (tests.size() >= limits.maxTests()) {
- capped[0] = true;
- break;
- }
- var r = reader.read(f, limits);
- tests.addAll(r.tests());
- warnings.addAll(r.warnings());
- }
- }
+ c.readDir(dir);
return FileVisitResult.SKIP_SUBTREE;
}
});
} catch (IOException e) {
- warnings.add("test reports unreadable: " + e.getClass().getSimpleName());
- found[0] = true;
+ c.warnings.add("test reports unreadable: " + e.getClass().getSimpleName());
+ c.found = true;
}
- if (! found[0])
+ if (! c.found)
return List.of();
- if (capped[0])
- warnings.add("test reports truncated at " + limits.maxTests() + " tests");
- return new ReportResult(reader.fw(), tests, warnings, capped[0], 0).toEvents(stepId);
+ if (c.capped)
+ c.warnings.add("test reports truncated at " + c.limits.maxTests() + " tests");
+ return new ReportResult(c.reader.fw(), c.tests, c.warnings, c.capped, 0).toEvents(stepId);
+ }
+
+ /**
+ * The reports read so far, and whether any were found or the test cap was reached.
+ */
+ private static final class Collector {
+ final ReportLimits limits = ReportLimits.DEFAULT;
+ final SurefireReportReader reader = new SurefireReportReader();
+ final List<ReportTest> tests = new ArrayList<>();
+ final List<String> warnings = new ArrayList<>();
+ final long cutoff;
+ boolean found;
+ boolean capped;
+
+ Collector(long cutoff) {
+ this.cutoff = cutoff;
+ }
+
+ /** Reads the fresh {@code TEST-*.xml} files in {@code dir}, stopping at the test cap. */
+ void readDir(Path dir) throws IOException {
+ try (var files = Files.newDirectoryStream(dir, "TEST-*.xml")) {
+ for (var f : files)
+ if (Files.getLastModifiedTime(f).toMillis() >= cutoff && ! read(f))
+ break;
+ }
+ }
+
+ /** Reads one report; returns false once the test cap is reached. */
+ private boolean read(Path f) {
+ found = true;
+ if (tests.size() >= limits.maxTests()) {
+ capped = true;
+ return false;
+ }
+ var r = reader.read(f, limits);
+ tests.addAll(r.tests());
+ warnings.addAll(r.warnings());
+ return true;
+ }
}
}
diff --git a/src/main/java/org/apache/juneau/releng/log/RunEventStore.java b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
index 8bc86202bf..2562518c56 100644
--- a/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
+++ b/src/main/java/org/apache/juneau/releng/log/RunEventStore.java
@@ -246,17 +246,15 @@ public class RunEventStore {
* The ids of the attempts of {@code stepId}, oldest first.
*/
private static List<String> attempts(Path file, String stepId) {
- List<String> out = new ArrayList<>();
- for (var id : scan(file).keySet())
- if (id.equals(stepId) || (id.startsWith(stepId + ".") && id.substring(stepId.length() + 1).chars().allMatch(Character::isDigit)))
- out.add(id);
- return out;
+ return scan(file).keySet().stream()
+ .filter(id -> id.equals(stepId) || (id.startsWith(stepId + ".") && id.substring(stepId.length() + 1).chars().allMatch(Character::isDigit)))
+ .toList();
}
private static List<String> openIds(Path file) {
List<String> out = new ArrayList<>();
scan(file).forEach((id, open) -> {
- if (open)
+ if (b(open))
out.add(id);
});
return out;
diff --git a/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java b/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
index 5c1b390fc9..4c1776e8d0 100644
--- a/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
+++ b/src/main/java/org/apache/juneau/releng/nexus/NexusStagingClient.java
@@ -161,7 +161,7 @@ public class NexusStagingClient {
// The raw status field may be named "type" or "state" depending on the endpoint; fall back
// to "state" when "type" is absent.
r.status = str(m.getOrDefault("type", m.get("state")));
- r.transitioning = Boolean.TRUE.equals(m.get("transitioning"));
+ r.transitioning = b(m.get("transitioning"));
r.created = str(m.get("created"));
r.description = str(m.get("description"));
return r;
@@ -181,7 +181,7 @@ public class NexusStagingClient {
r.id = str(m.get("repositoryId"));
r.profileId = str(m.get("profileId"));
r.status = str(m.getOrDefault("type", m.get("state")));
- r.transitioning = Boolean.TRUE.equals(m.get("transitioning"));
+ r.transitioning = b(m.get("transitioning"));
return r;
}
diff --git a/src/main/java/org/apache/juneau/releng/release/GithubReleaseSource.java b/src/main/java/org/apache/juneau/releng/release/GithubReleaseSource.java
index e50ffa088a..ac12e6fe57 100644
--- a/src/main/java/org/apache/juneau/releng/release/GithubReleaseSource.java
+++ b/src/main/java/org/apache/juneau/releng/release/GithubReleaseSource.java
@@ -17,6 +17,8 @@
package org.apache.juneau.releng.release;
+import static org.apache.juneau.commons.utils.Shorts.*;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -54,7 +56,7 @@ public class GithubReleaseSource {
for (var m : parsed) {
var tag = String.valueOf(m.getOrDefault("tag_name", ""));
var v = ReleaseVersion.ofTag(tag);
- var draft = Boolean.TRUE.equals(m.get("draft"));
+ var draft = b(m.get("draft"));
var r = new Release(v.version(), draft ? "DRAFT" : "RELEASED", "github");
r.stage = "Distributed";
r.githubReleaseUrl = str(m.get("html_url"));
diff --git a/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java b/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
index 80e4366d7d..2db4b574fd 100644
--- a/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
+++ b/src/main/java/org/apache/juneau/releng/rest/ReleaseRest.java
@@ -67,6 +67,9 @@ import jakarta.servlet.http.HttpServletRequest;
* {@code /juneau-datatables.js} glue that defines {@code JuneauDataTables.ajax()}, and the composed {@link WebJarsMixin}
* serves the jQuery, DataTables and Buttons libraries the card's asset packs load.
*/
+@SuppressWarnings({
+ "java:S1192" // WebJar coordinates read more clearly inline than as constants.
+})
@Rest(path = "/releases", title = "Releases", responseProcessors = FreemarkerViewRenderer.class, mixins = { ViewsMixin.class, DataTablesMixin.class, WebJarsMixin.class })
public class ReleaseRest extends BasicRestResource {
diff --git a/src/main/java/org/apache/juneau/releng/setup/SetupProbeService.java b/src/main/java/org/apache/juneau/releng/setup/SetupProbeService.java
index c6f8af5e2a..32907b305e 100644
--- a/src/main/java/org/apache/juneau/releng/setup/SetupProbeService.java
+++ b/src/main/java/org/apache/juneau/releng/setup/SetupProbeService.java
@@ -17,6 +17,8 @@
package org.apache.juneau.releng.setup;
+import static org.apache.juneau.commons.utils.Shorts.*;
+
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
@@ -233,7 +235,7 @@ public class SetupProbeService {
warn(p, "Stored — not tested");
return p;
}
- if (Boolean.TRUE.equals(st.lastValid))
+ if (b(st.lastValid))
pass(p, spec.label + " is valid");
else
fail(p, spec.label + " failed validation");
diff --git a/src/main/java/org/apache/juneau/releng/util/DefaultProcessRunner.java b/src/main/java/org/apache/juneau/releng/util/DefaultProcessRunner.java
index 697cd066d4..b25e131d58 100644
--- a/src/main/java/org/apache/juneau/releng/util/DefaultProcessRunner.java
+++ b/src/main/java/org/apache/juneau/releng/util/DefaultProcessRunner.java
@@ -39,8 +39,6 @@ import java.util.function.Consumer;
* </p>
*/
public class DefaultProcessRunner implements ProcessRunner {
- private static final String MSG_INTERRUPTED = "Interrupted running: %s";
- private static final String MSG_ERROR = "Error running: %s";
private static final int CODE_TIMEOUT = 124;
@Override
@@ -120,9 +118,9 @@ public class DefaultProcessRunner implements ProcessRunner {
return new ProcResult(p.exitValue(), sb.toString());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw isex(e, MSG_INTERRUPTED, command);
+ throw isex(e, "Interrupted running: %s", command);
} catch (Exception e) {
- throw isex(e, MSG_ERROR, command);
+ throw isex(e, "Error running: %s", command);
}
}
}
diff --git a/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java
index e78c11c790..000c1c6573 100644
--- a/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java
+++ b/src/test/java/org/apache/juneau/releng/engine/ReleaseEngineRunViewTest.java
@@ -38,10 +38,11 @@ import org.junit.jupiter.api.io.TempDir;
* The engine's mirror of each step into the run-view event stream: one step per invocation, how it ended, the notes it
* recorded, and the test results of the Maven steps.
*/
+@SuppressWarnings({
+ "java:S1192" // Fixture version and step ids read more clearly inline than as constants.
+})
class ReleaseEngineRunViewTest {
- private static final String V = "9.2.1";
-
private static final String REPORT = """
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="org.example.FooTest" tests="2" failures="%d" errors="0" skipped="0" time="0.5">
@@ -108,7 +109,7 @@ class ReleaseEngineRunViewTest {
private void satisfyAllPredecessorsOf(Path dir, String stepId) {
var store = new RunStateStore(dir);
- var rs = store.load(V).orElseThrow();
+ var rs = store.load("9.2.1").orElseThrow();
var ids = StepRegistry.standard(new BranchResolver(runner(dir, 0, false), "/repo")).ids();
for (var i = 0; i < ids.indexOf(stepId); i++)
rs.step(ids.get(i)).status = StepStatus.SUCCEEDED;
@@ -116,7 +117,7 @@ class ReleaseEngineRunViewTest {
}
private List<RunEvent> events(ReleaseEngine eng) {
- return eng.runViewSource(V.replace('.', '_')).orElseThrow().page(null, 5000).events();
+ return eng.runViewSource("9_2_1").orElseThrow().page(null, 5000).events();
}
/** One compact token per event: {@code step:id}, {@code end:id:status}, {@code note:level:step}, {@code test:status}. */
@@ -142,8 +143,8 @@ class ReleaseEngineRunViewTest {
@Test
void a01_aSuccessfulStepIsAStepThenAnOkEnd(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
- eng.apply(V, "preflight", Map.of());
+ eng.start("9.2.1", null);
+ eng.apply("9.2.1", "preflight", Map.of());
assertEquals(List.of("step:preflight", "end:preflight:ok"), summary(eng));
var step = first(eng, RunEvent.Kind.STEP);
@@ -155,11 +156,11 @@ class ReleaseEngineRunViewTest {
@Test
void a02_aFailedStepEndsFailAndAResumeIsANewAttempt(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "tally-vote-result");
- assertFalse(eng.apply(V, "tally-vote-result", Map.of()).success);
- assertTrue(eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line")).success);
+ assertFalse(eng.apply("9.2.1", "tally-vote-result", Map.of()).success);
+ assertTrue(eng.apply("9.2.1", "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line")).success);
assertEquals(List.of("step:tally-vote-result", "end:tally-vote-result:fail", "step:tally-vote-result.2",
"note:info:tally-vote-result.2", "end:tally-vote-result.2:ok"), summary(eng).stream().filter(s -> ! s.startsWith("end:vote-gate")).toList());
@@ -170,13 +171,13 @@ class ReleaseEngineRunViewTest {
@Test
void a03_theVoteGateStaysOpenAsWaitingUntilTheTallyPasses(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "vote-gate");
- eng.apply(V, "vote-gate", Map.of());
+ eng.apply("9.2.1", "vote-gate", Map.of());
assertEquals(List.of("step:vote-gate", "step:vote-gate:waiting"), summary(eng));
- eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line"));
+ eng.apply("9.2.1", "tally-vote-result", Map.of("voteOutcome", "passed", "tally", "+3 binding\nsecond line"));
var tail = summary(eng).subList(2, summary(eng).size());
assertEquals(List.of("step:tally-vote-result", "note:info:tally-vote-result", "end:vote-gate:ok", "end:tally-vote-result:ok"), tail);
var note = events(eng).stream().filter(e -> e.kind() == RunEvent.Kind.NOTE).findFirst().orElseThrow().toContractMap();
@@ -186,11 +187,11 @@ class ReleaseEngineRunViewTest {
@Test
void a04_aRejectedTallyIsAWarningAndLeavesTheGateWaiting(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "vote-gate");
- eng.apply(V, "vote-gate", Map.of());
+ eng.apply("9.2.1", "vote-gate", Map.of());
- eng.apply(V, "tally-vote-result", Map.of("voteOutcome", "rejected"));
+ eng.apply("9.2.1", "tally-vote-result", Map.of("voteOutcome", "rejected"));
var s = summary(eng);
assertTrue(s.contains("note:warn:tally-vote-result"), s.toString());
@@ -200,22 +201,22 @@ class ReleaseEngineRunViewTest {
@Test
void a05_aReviewGateWaitsThenEndsWhenConfirmed(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "javadoc-verify");
- eng.apply(V, "javadoc-verify", Map.of());
+ eng.apply("9.2.1", "javadoc-verify", Map.of());
assertEquals(List.of("step:javadoc-verify", "step:javadoc-verify:waiting"), summary(eng));
- eng.confirmReview(V, "javadoc-verify");
+ eng.confirmReview("9.2.1", "javadoc-verify");
assertEquals("end:javadoc-verify:ok", summary(eng).get(2));
}
@Test
void a06_aSkippedStepIsAStepThenASkipEnd(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
- eng.skip(V, "test-workspace-verify");
+ eng.skip("9.2.1", "test-workspace-verify");
assertEquals(List.of("step:test-workspace-verify", "end:test-workspace-verify:skip"), summary(eng));
}
@@ -223,10 +224,10 @@ class ReleaseEngineRunViewTest {
@Test
void a07_composedEmailsAreNotesUnderTheirStep(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "compose-propose-email");
- eng.apply(V, "compose-propose-email", Map.of());
+ eng.apply("9.2.1", "compose-propose-email", Map.of());
assertEquals(List.of("step:compose-propose-email", "note:info:compose-propose-email", "end:compose-propose-email:ok"), summary(eng));
var text = (String)first(eng, RunEvent.Kind.NOTE).get("text");
@@ -237,10 +238,10 @@ class ReleaseEngineRunViewTest {
@Test
void b01_aMavenStepFeedsItsFreshSurefireReportsBeforeItEnds(@TempDir Path dir) {
var eng = engine(dir, runner(dir, 0, true));
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "build-verify");
- eng.apply(V, "build-verify", Map.of());
+ eng.apply("9.2.1", "build-verify", Map.of());
assertEquals(List.of("step:build-verify", "replace", "test:pass", "test:pass", "end:build-verify:ok"), summary(eng));
var test = first(eng, RunEvent.Kind.TEST);
@@ -252,10 +253,10 @@ class ReleaseEngineRunViewTest {
@Test
void b02_aFailingMavenStepKeepsTheFailedTestsAndEndsFail(@TempDir Path dir) {
var eng = engine(dir, runner(dir, 1, true));
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "build-verify");
- assertFalse(eng.apply(V, "build-verify", Map.of()).success);
+ assertFalse(eng.apply("9.2.1", "build-verify", Map.of()).success);
assertEquals(List.of("step:build-verify", "replace", "test:pass", "test:fail", "end:build-verify:fail"), summary(eng));
}
@@ -265,10 +266,10 @@ class ReleaseEngineRunViewTest {
var stale = writeReport(dir, true);
Files.setLastModifiedTime(stale, FileTime.fromMillis(1_000));
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "build-verify");
- eng.apply(V, "build-verify", Map.of());
+ eng.apply("9.2.1", "build-verify", Map.of());
assertEquals(List.of("step:build-verify", "end:build-verify:ok"), summary(eng));
}
@@ -276,12 +277,12 @@ class ReleaseEngineRunViewTest {
@Test
void c01_finalizingTheRunIsDoneAndMakesTheSourceTerminal(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "finalize-run");
var source = eng.runViewSource("9_2_1").orElseThrow();
assertFalse(source.page(null, 100).terminal());
- eng.apply(V, "finalize-run", Map.of());
+ eng.apply("9.2.1", "finalize-run", Map.of());
var s = summary(eng);
assertEquals(List.of("step:finalize-run", "end:finalize-run:ok", "done"), s);
@@ -291,7 +292,7 @@ class ReleaseEngineRunViewTest {
@Test
void c02_aRunNobodyStartedHasNoSource(@TempDir Path dir) {
var eng = engine(dir);
- eng.start(V, null);
+ eng.start("9.2.1", null);
assertTrue(eng.runViewSource("9_9_9").isEmpty());
assertTrue(eng.runViewSource("9_2_1").isPresent());
assertTrue(eng.runViewSource("9_2_1").orElseThrow().page(null, 100).events().isEmpty(), "nothing has run yet");
@@ -300,10 +301,10 @@ class ReleaseEngineRunViewTest {
@Test
void c03_aStepInterruptedByARestartEndsFail(@TempDir Path dir) {
var eng = engine(dir);
- var rs = eng.start(V, null);
- eng.runEvents().begin(V, "preflight", "Preflight", 1);
+ eng.start("9.2.1", null);
+ eng.runEvents().begin("9.2.1", "preflight", "Preflight", 1);
var store = new RunStateStore(dir);
- rs = store.load(V).orElseThrow();
+ var rs = store.load("9.2.1").orElseThrow();
rs.step("preflight").status = StepStatus.RUNNING;
rs.currentStepId = "preflight";
store.save(rs);
@@ -317,13 +318,13 @@ class ReleaseEngineRunViewTest {
void c04_droppingTheCandidateEndsOpenStepsAndSaysSo(@TempDir Path dir) {
var runner = runner(dir, 0, false);
var eng = engine(dir, runner);
- eng.start(V, null);
+ eng.start("9.2.1", null);
satisfyAllPredecessorsOf(dir, "vote-gate");
- eng.apply(V, "vote-gate", Map.of());
+ eng.apply("9.2.1", "vote-gate", Map.of());
var drop = new DropRcService(new RunStateStore(dir), eng.registry(), runner, dir.resolve("staging/git/juneau"), dir,
NexusStagingClient.forTests((m, p, b) -> ""), TargetProfile.prodDefault(), eng.runEvents());
- drop.apply(V, "vote rejected", () -> "me", () -> "pw");
+ drop.apply("9.2.1", "vote rejected", () -> "me", () -> "pw");
var s = summary(eng);
assertEquals(List.of("step:vote-gate", "step:vote-gate:waiting", "end:vote-gate:skip", "note:warn:null"), s);
diff --git a/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java b/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java
index b581e5bef6..55ca082233 100644
--- a/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java
+++ b/src/test/java/org/apache/juneau/releng/log/StepOutputSourcesTest.java
@@ -29,15 +29,15 @@ import org.apache.juneau.rest.server.views.ConsoleOutputLine.Style;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
+@SuppressWarnings({
+ "java:S1192" // Fixture version and step ids read more clearly inline than as constants.
+})
class StepOutputSourcesTest {
- private static final String VERSION = "9.2.1";
- private static final String STEP = "preflight";
-
private RunStateStore storeWithRun(Path dir, StepStatus status, String logRef) {
var store = new RunStateStore(dir);
- var rs = RunState.create(VERSION, "juneau-9.2.1-branch", List.of(STEP, "workspace-setup"));
- var step = rs.step(STEP);
+ var rs = RunState.create("9.2.1", "juneau-9.2.1-branch", List.of("preflight", "workspace-setup"));
+ var step = rs.step("preflight");
step.status = status;
step.logRef = logRef;
step.startedAt = "2026-10-08T10:00:00Z";
@@ -51,16 +51,16 @@ class StepOutputSourcesTest {
void a01_unknownRunStepOrNeverWrittenLogHasNoSource(@TempDir Path dir) {
var store = storeWithRun(dir, StepStatus.PENDING, null);
var sources = new StepOutputSources(store);
- assertTrue(sources.find("nope", STEP).isEmpty());
- assertTrue(sources.find(VERSION, "not-a-step").isEmpty());
- assertTrue(sources.find(VERSION, STEP).isEmpty(), "no logRef until the step first runs");
+ assertTrue(sources.find("nope", "preflight").isEmpty());
+ assertTrue(sources.find("9.2.1", "not-a-step").isEmpty());
+ assertTrue(sources.find("9.2.1", "preflight").isEmpty(), "no logRef until the step first runs");
}
@Test
void a02_logRefEscapingTheStateDirIsRefused(@TempDir Path dir) throws Exception {
var outside = Files.writeString(dir.getParent().resolve("outside-" + dir.getFileName() + ".log"), "secret\n");
var store = storeWithRun(dir, StepStatus.SUCCEEDED, "../" + outside.getFileName());
- assertTrue(new StepOutputSources(store).find(VERSION, STEP).isEmpty());
+ assertTrue(new StepOutputSources(store).find("9.2.1", "preflight").isEmpty());
}
@Test
@@ -69,13 +69,13 @@ class StepOutputSourcesTest {
Files.writeString(dir.resolve("logs/step.log"), "first\nsecond\n");
var sources = new StepOutputSources(storeWithRun(dir, StepStatus.SUCCEEDED, "logs/step.log"));
- var src = sources.find(VERSION, STEP).orElseThrow();
+ var src = sources.find("9.2.1", "preflight").orElseThrow();
var page = src.page(null, 100);
var contract = page.toContractMap();
assertEquals(2, ((List<?>)contract.get("lines")).size());
assertEquals(Boolean.TRUE, contract.get("terminal"));
- assertSame(src, sources.find(VERSION, STEP).orElseThrow());
+ assertSame(src, sources.find("9.2.1", "preflight").orElseThrow());
}
@Test
@@ -90,7 +90,7 @@ class StepOutputSourcesTest {
StepStatus.AWAITING_REVIEW, List.of("AWAITING REVIEW", true));
for (var e : expect.entrySet()) {
var sources = new StepOutputSources(storeWithRun(dir, e.getKey(), "logs/step.log"));
- var st = sources.status(VERSION, STEP);
+ var st = sources.status("9.2.1", "preflight");
assertEquals(e.getValue().get(0), st.state(), e.getKey().name());
assertEquals(e.getValue().get(1), st.terminal(), e.getKey().name());
}
@@ -98,7 +98,7 @@ class StepOutputSourcesTest {
@Test
void b02_settledStepReportsStyleAndServerDuration(@TempDir Path dir) {
- var st = new StepOutputSources(storeWithRun(dir, StepStatus.FAILED, "logs/step.log")).status(VERSION, STEP);
+ var st = new StepOutputSources(storeWithRun(dir, StepStatus.FAILED, "logs/step.log")).status("9.2.1", "preflight");
assertEquals(Style.ERROR, st.stateStyle());
assertEquals(Instant.parse("2026-10-08T10:00:00Z"), st.startedAt());
assertEquals(83_000L, st.durationMs());
@@ -106,7 +106,7 @@ class StepOutputSourcesTest {
@Test
void b03_runningStepHasNoDurationYet(@TempDir Path dir) {
- var st = new StepOutputSources(storeWithRun(dir, StepStatus.RUNNING, "logs/step.log")).status(VERSION, STEP);
+ var st = new StepOutputSources(storeWithRun(dir, StepStatus.RUNNING, "logs/step.log")).status("9.2.1", "preflight");
assertEquals(Style.ACCENT, st.stateStyle());
assertNull(st.durationMs());
}
@@ -114,10 +114,10 @@ class StepOutputSourcesTest {
@Test
void b04_unparseableTimestampsDegradeToNoDuration(@TempDir Path dir) {
var store = storeWithRun(dir, StepStatus.SUCCEEDED, "logs/step.log");
- var rs = store.load(VERSION).orElseThrow();
- rs.step(STEP).startedAt = "not-a-time";
+ var rs = store.load("9.2.1").orElseThrow();
+ rs.step("preflight").startedAt = "not-a-time";
store.save(rs);
- var st = new StepOutputSources(store).status(VERSION, STEP);
+ var st = new StepOutputSources(store).status("9.2.1", "preflight");
assertNull(st.startedAt());
assertNull(st.durationMs());
}