diff options
author | Jacek <jacek.poreda@sonarsource.com> | 2022-05-30 18:50:42 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-05-31 20:02:50 +0000 |
commit | 9097b10693f9c4fe2c7bde4bccdbca151ebfa452 (patch) | |
tree | 10eb71dfd890e5725f4f085386812eeb65c53197 /sonar-core | |
parent | cdeca9bf6ccd0cb1a3b2d397efa8ace1ef4789c2 (diff) | |
download | sonarqube-9097b10693f9c4fe2c7bde4bccdbca151ebfa452.tar.gz sonarqube-9097b10693f9c4fe2c7bde4bccdbca151ebfa452.zip |
SONAR-16232 Use plugin api version for SonarRuntime impl
- introduce internal SonarQubeVersion
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/platform/SonarQubeVersion.java | 55 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/platform/SonarQubeVersionTest.java | 39 |
2 files changed, 94 insertions, 0 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/SonarQubeVersion.java b/sonar-core/src/main/java/org/sonar/core/platform/SonarQubeVersion.java new file mode 100644 index 00000000000..322fcc372ff --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/platform/SonarQubeVersion.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.platform; + +import javax.annotation.concurrent.Immutable; +import org.sonar.api.ce.ComputeEngineSide; +import org.sonar.api.scanner.ScannerSide; +import org.sonar.api.server.ServerSide; +import org.sonar.api.utils.Version; + +import static java.util.Objects.requireNonNull; + +@ScannerSide +@ServerSide +@ComputeEngineSide +@Immutable +public class SonarQubeVersion { + + private final Version version; + + public SonarQubeVersion(Version version) { + requireNonNull(version); + this.version = version; + } + + public Version get() { + return this.version; + } + + public boolean isGreaterThanOrEqual(Version than) { + return this.version.isGreaterThanOrEqual(than); + } + + @Override + public String toString() { + return version.toString(); + } +} diff --git a/sonar-core/src/test/java/org/sonar/core/platform/SonarQubeVersionTest.java b/sonar-core/src/test/java/org/sonar/core/platform/SonarQubeVersionTest.java new file mode 100644 index 00000000000..5a457f05034 --- /dev/null +++ b/sonar-core/src/test/java/org/sonar/core/platform/SonarQubeVersionTest.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2022 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.platform; + +import org.junit.Test; +import org.sonar.api.utils.Version; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SonarQubeVersionTest { + + @Test + public void verify_methods() { + var version = Version.create(9, 5); + SonarQubeVersion underTest = new SonarQubeVersion(version); + assertThat(underTest).extracting(SonarQubeVersion::toString, SonarQubeVersion::get) + .containsExactly("9.5", version); + + var otherVersion = Version.create(8, 5); + assertThat(underTest.isGreaterThanOrEqual(otherVersion)).isTrue(); + } +} |