use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultServerTest method invalid_startup_date_throws_exception.
@Test(expected = RuntimeException.class)
public void invalid_startup_date_throws_exception() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_STARTTIME, "invalid");
ScannerWsClient client = mock(ScannerWsClient.class);
DefaultServer metadata = new DefaultServer(settings, client, null);
metadata.getStartedAt();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultServerTest method shouldLoadServerProperties.
@Test
public void shouldLoadServerProperties() {
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");
ScannerWsClient client = mock(ScannerWsClient.class);
when(client.baseUrl()).thenReturn("http://foo.com");
DefaultServer metadata = new DefaultServer(settings, client, SonarRuntimeImpl.forSonarQube(Version.parse("2.2"), SonarQubeSide.SCANNER));
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isEqualTo("http://foo.com");
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
assertThat(metadata.getRootDir()).isNull();
assertThat(metadata.getDeployDir()).isNull();
assertThat(metadata.getContextPath()).isNull();
assertThat(metadata.isDev()).isFalse();
assertThat(metadata.isSecured()).isFalse();
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class MetadataPublisherTest method prepare.
@Before
public void prepare() {
projectDef = ProjectDefinition.create().setKey("foo");
rootModule = new DefaultInputModule(projectDef, TestInputFileBuilder.nextBatchId());
projectAnalysisInfo = mock(ProjectAnalysisInfo.class);
when(projectAnalysisInfo.analysisDate()).thenReturn(new Date(1234567L));
inputModuleHierarchy = mock(InputModuleHierarchy.class);
when(inputModuleHierarchy.root()).thenReturn(rootModule);
settings = new MapSettings();
qProfiles = mock(ModuleQProfiles.class);
underTest = new MetadataPublisher(projectAnalysisInfo, inputModuleHierarchy, settings, qProfiles);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultSensorContextTest method prepare.
@Before
public void prepare() throws Exception {
activeRules = new ActiveRulesBuilder().build();
fs = new DefaultFileSystem(temp.newFolder().toPath());
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
settings = new MapSettings();
sensorStorage = mock(SensorStorage.class);
analysisMode = mock(AnalysisMode.class);
runtime = SonarRuntimeImpl.forSonarQube(Version.parse("5.5"), SonarQubeSide.SCANNER);
adaptor = new DefaultSensorContext(mock(InputModule.class), settings, fs, activeRules, analysisMode, sensorStorage, runtime);
}
use of org.sonar.api.config.MapSettings in project sonarqube by SonarSource.
the class DefaultSensorStorageTest method prepare.
@Before
public void prepare() throws Exception {
MetricFinder metricFinder = mock(MetricFinder.class);
when(metricFinder.<Integer>findByKey(CoreMetrics.NCLOC_KEY)).thenReturn(CoreMetrics.NCLOC);
when(metricFinder.<String>findByKey(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION_KEY)).thenReturn(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION);
settings = new MapSettings();
moduleIssues = mock(ModuleIssues.class);
measureCache = mock(MeasureCache.class);
CoverageExclusions coverageExclusions = mock(CoverageExclusions.class);
when(coverageExclusions.isExcluded(any(InputFile.class))).thenReturn(false);
ReportPublisher reportPublisher = mock(ReportPublisher.class);
when(reportPublisher.getWriter()).thenReturn(new ScannerReportWriter(temp.newFolder()));
underTest = new DefaultSensorStorage(metricFinder, moduleIssues, settings, coverageExclusions, reportPublisher, measureCache, mock(SonarCpdBlockIndex.class), contextPropertiesCache, new ScannerMetrics());
}
Aggregations