use of org.sonar.api.SonarRuntime in project sonar-web by SonarSource.
the class HtmlSensorTest method test_descriptor_sonarlint.
@Test
public void test_descriptor_sonarlint() {
DefaultSensorDescriptor sensorDescriptor = new DefaultSensorDescriptor();
SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarLint(Version.create(6, 5));
new HtmlSensor(sonarRuntime, null, null, new CheckFactory(new DefaultActiveRules(Collections.emptyList()))).describe(sensorDescriptor);
assertThat(sensorDescriptor.name()).isEqualTo("HTML");
assertThat(sensorDescriptor.languages()).isEmpty();
}
use of org.sonar.api.SonarRuntime in project sonar-web by SonarSource.
the class HtmlSensorTest method setUp.
@Before
public void setUp() {
HtmlRulesDefinition rulesDefinition = new HtmlRulesDefinition();
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
RulesDefinition.Repository repository = context.repository(HtmlRulesDefinition.REPOSITORY_KEY);
List<NewActiveRule> ar = new ArrayList<>();
for (RulesDefinition.Rule rule : repository.rules()) {
ar.add(new NewActiveRule.Builder().setRuleKey(RuleKey.of(HtmlRulesDefinition.REPOSITORY_KEY, rule.key())).build());
}
ActiveRules activeRules = new DefaultActiveRules(ar);
CheckFactory checkFactory = new CheckFactory(activeRules);
FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
final SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(8, 9), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
sensor = new HtmlSensor(sonarRuntime, new NoSonarFilter(), fileLinesContextFactory, checkFactory);
tester = SensorContextTester.create(TEST_DIR).setRuntime(sonarRuntime);
}
use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.
the class XooPluginTest method provide_extensions_for_5_4.
@Test
public void provide_extensions_for_5_4() {
SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.parse("5.4"));
Plugin.Context context = new Plugin.Context(runtime);
new XooPlugin().define(context);
assertThat(context.getExtensions()).hasSize(44).doesNotContain(CpdTokenizerSensor.class);
}
use of org.sonar.api.SonarRuntime in project sonarlint-core by SonarSource.
the class DefaultServerTest method shouldLoadServerProperties.
@Test
public void shouldLoadServerProperties() {
SonarRuntime runtime = mock(SonarRuntime.class);
when(runtime.getApiVersion()).thenReturn(Version.create(2, 2));
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_ID, "123");
settings.setProperty(CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000");
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, "abcde");
DefaultServer metadata = new DefaultServer(settings, runtime);
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isNull();
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
}
use of org.sonar.api.SonarRuntime in project sonar-java by SonarSource.
the class JavaPluginTest method sonarqube_6_7_extensions.
@Test
public void sonarqube_6_7_extensions() {
SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(VERSION_6_7, SonarQubeSide.SERVER);
Plugin.Context context = new Plugin.Context(runtime);
javaPlugin.define(context);
assertThat(context.getExtensions()).hasSize(24);
}
Aggregations