From 9a97d5fd098340ab9c8e5816b97cbe34696a7229 Mon Sep 17 00:00:00 2001 From: Lenny Angst Date: Sun, 8 Aug 2021 05:47:38 +0200 Subject: [PATCH] Bugfixes and improvements --- .idea/.gitignore | 1 + .idea/sonarlint/issuestore/index.pb | 16 ---------------- .../githubversionchecker/ReleaseVersion.java | 10 +++++----- .../GithubVersionCheckerTest.java | 10 ++++++++++ 4 files changed, 16 insertions(+), 21 deletions(-) delete mode 100644 .idea/sonarlint/issuestore/index.pb diff --git a/.idea/.gitignore b/.idea/.gitignore index 73f69e0..2cf7047 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -6,3 +6,4 @@ /dataSources.local.xml # Editor-based HTTP Client requests /httpRequests/ +/sonarlint/ diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb deleted file mode 100644 index bce5c90..0000000 --- a/.idea/sonarlint/issuestore/index.pb +++ /dev/null @@ -1,16 +0,0 @@ - -; - gradlew.bat,2/a/2a45a911a8f1836b0b6c5b758962572012d8f8c3 -S -#.idea/sonarlint/issuestore/index.pb,9/f/9fe84ebb15faf917b7def6236dba604453cc61e0 -: - -.gitignore,a/5/a5cc2925ca8258af241be7e5b0381edf30266302 -7 -gradlew,5/b/5bbfa66edb4db3c7c33c5181f43510990d3307f9 -X -(gradle/wrapper/gradle-wrapper.properties,f/b/fbe448ebfc3eb2d4e308f6b8b043666f5b57235e -? -settings.gradle,0/5/05efc8b1657769a27696d478ded1e95f38737233 -< - build.gradle,f/0/f07866736216be0ee2aba49e392191aeae700a35 \ No newline at end of file diff --git a/src/main/java/com/lezurex/githubversionchecker/ReleaseVersion.java b/src/main/java/com/lezurex/githubversionchecker/ReleaseVersion.java index 50f774c..73b2c68 100644 --- a/src/main/java/com/lezurex/githubversionchecker/ReleaseVersion.java +++ b/src/main/java/com/lezurex/githubversionchecker/ReleaseVersion.java @@ -32,7 +32,7 @@ public ReleaseVersion(int major, int minor, int patch) { } public ReleaseVersion(String versionString) { - + parseVersionString(versionString); } private void parseVersionString(String s) { @@ -40,10 +40,10 @@ private void parseVersionString(String s) { final Matcher matcher = pattern.matcher(s); if (matcher.find()) { - for (int i = 1; i < matcher.groupCount(); i++) { - if (i == 1) this.major = Integer.parseInt(matcher.group()); - if (i == 2) this.minor = Integer.parseInt(matcher.group()); - if (i == 3) this.patch = Integer.parseInt(matcher.group()); + for (int i = 1; i <= matcher.groupCount(); i++) { + if (i == 1) this.major = Integer.parseInt(matcher.group(i)); + if (i == 2) this.minor = Integer.parseInt(matcher.group(i)); + if (i == 3) this.patch = Integer.parseInt(matcher.group(i)); } } else throw new InvalidVersionString(s); } diff --git a/src/test/java/com/lezurex/githubversionchecker/GithubVersionCheckerTest.java b/src/test/java/com/lezurex/githubversionchecker/GithubVersionCheckerTest.java index 78f0deb..c7ff79c 100644 --- a/src/test/java/com/lezurex/githubversionchecker/GithubVersionCheckerTest.java +++ b/src/test/java/com/lezurex/githubversionchecker/GithubVersionCheckerTest.java @@ -24,4 +24,14 @@ void setupInvalidRepo() { assertThrows(RepoNotFoundException.class, () -> new GithubVersionChecker("Lezurex", "doesnotexist", releaseVersion), "Repo validation di not fail!"); } + @Test + @DisplayName("Check with outdated version") + void checkOutdated() { + ReleaseVersion releaseVersion = new ReleaseVersion("0.0.1"); + GithubVersionChecker githubVersionChecker = new GithubVersionChecker("VoxCrafterLP", "JumpRace", releaseVersion); + CheckResult checkResult = githubVersionChecker.check(); + assertEquals(VersionState.OUTDATED, checkResult.getVersionState(), "Version state is not outdated!"); + assertTrue(checkResult.getPageLink().endsWith(checkResult.getVersion().toString()), "End of release URL does not match version!"); + } + } \ No newline at end of file