use of org.sonar.plugins.java.api.JavaVersion in project sonar-java by SonarSource.
the class JavaVersionImplTest method test_fromString.
@Test
public void test_fromString() throws Exception {
JavaVersion version;
version = JavaVersionImpl.fromString(null);
assertThat(version.isNotSet()).isTrue();
assertThat(version.asInt()).isEqualTo(-1);
version = JavaVersionImpl.fromString("jdk1.6");
assertThat(version.isNotSet()).isTrue();
assertThat(version.asInt()).isEqualTo(-1);
version = JavaVersionImpl.fromString("1.6");
assertThat(version.isNotSet()).isFalse();
assertThat(version.asInt()).isEqualTo(6);
version = JavaVersionImpl.fromString("7");
assertThat(version.isNotSet()).isFalse();
assertThat(version.asInt()).isEqualTo(7);
}
use of org.sonar.plugins.java.api.JavaVersion in project sonar-java by SonarSource.
the class JavaVersionImplTest method compatibilityMesssages.
@Test
public void compatibilityMesssages() throws Exception {
JavaVersion version;
version = new JavaVersionImpl();
assertThat(version.java7CompatibilityMessage()).isEqualTo(" (sonar.java.source not set. Assuming 7 or greater.)");
assertThat(version.java8CompatibilityMessage()).isEqualTo(" (sonar.java.source not set. Assuming 8 or greater.)");
version = new JavaVersionImpl(6);
assertThat(version.java7CompatibilityMessage()).isEmpty();
assertThat(version.java8CompatibilityMessage()).isEmpty();
}
use of org.sonar.plugins.java.api.JavaVersion in project sonar-java by SonarSource.
the class JavaSquidSensor method getJavaVersion.
private JavaVersion getJavaVersion() {
JavaVersion javaVersion = JavaVersionImpl.fromString(settings.get(Java.SOURCE_VERSION).orElse(null));
LOG.info("Configured Java source version (" + Java.SOURCE_VERSION + "): " + javaVersion);
return javaVersion;
}
use of org.sonar.plugins.java.api.JavaVersion in project sonar-java by SonarSource.
the class JavaVersionImplTest method test_toString.
@Test
public void test_toString() throws Exception {
JavaVersion version;
version = new JavaVersionImpl();
assertThat(version.toString()).isEqualTo("none");
version = new JavaVersionImpl(7);
assertThat(version.toString()).isEqualTo("7");
}
use of org.sonar.plugins.java.api.JavaVersion in project sonar-java by SonarSource.
the class JavaVersionImplTest method no_version_set.
@Test
public void no_version_set() throws Exception {
JavaVersion version = new JavaVersionImpl();
assertThat(version.isJava7Compatible()).isTrue();
assertThat(version.isJava8Compatible()).isTrue();
assertThat(version.asInt()).isEqualTo(-1);
}
Aggregations