From cc2351177329f9fe9024493c86b6a93b73fd4ecc Mon Sep 17 00:00:00 2001 From: Davide Angelocola Date: Tue, 19 Dec 2023 17:02:37 +0100 Subject: [PATCH] trying to fix --- .../java/hosh/runtime/VersionLoaderTest.java | 12 ++++++------ spi/src/main/java/hosh/spi/Version.java | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/runtime/src/test/java/hosh/runtime/VersionLoaderTest.java b/runtime/src/test/java/hosh/runtime/VersionLoaderTest.java index 051b924f..efd7baa9 100644 --- a/runtime/src/test/java/hosh/runtime/VersionLoaderTest.java +++ b/runtime/src/test/java/hosh/runtime/VersionLoaderTest.java @@ -23,7 +23,7 @@ */ package hosh.runtime; -import hosh.spi.*; +import hosh.spi.Version; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -32,10 +32,10 @@ class VersionLoaderTest { - @Test - void loadVersionViaGit() throws IOException { - Version result= VersionLoader.loadVersion(); - assertThat(result).isNotNull(); // must be always defined - } + @Test + void loadVersionViaGit() throws IOException { + Version result = VersionLoader.loadVersion(); + assertThat(result).isNotNull(); // must be always defined + } } diff --git a/spi/src/main/java/hosh/spi/Version.java b/spi/src/main/java/hosh/spi/Version.java index 23f63a42..f2edd39e 100644 --- a/spi/src/main/java/hosh/spi/Version.java +++ b/spi/src/main/java/hosh/spi/Version.java @@ -30,22 +30,22 @@ public class Version { private final String value; - public Version(String value) { - if (value == null) { + public Version(String candidate) { + if (candidate == null) { throw new IllegalArgumentException("null version"); } - if (value.isBlank()) { + if (candidate.isBlank()) { throw new IllegalArgumentException("empty version"); } - final String[] split = value.split("\\."); + final String[] split = candidate.split("\\."); if (!split[0].startsWith("v")) { - throw new IllegalArgumentException("missing prefix"); + throw new IllegalArgumentException("missing prefix: " + candidate); } if (split.length != 3) { // expecting to follow our maven conventions of major.minor.patch - throw new IllegalArgumentException("invalid maven version"); + throw new IllegalArgumentException("invalid maven version: " + candidate); } - // at this point value is fully validated, but it is never exposed directly - this.value = value; + // at this point candidate is fully validated + this.value = candidate; } /**