Search in sources :

Example 1 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectRepositoriesProviderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    Table<String, String, String> t1 = HashBasedTable.create();
    Table<String, String, FileData> t2 = HashBasedTable.create();
    project = new ProjectRepositories(t1, t2, new Date());
    provider = new ProjectRepositoriesProvider();
    when(projectKey.get()).thenReturn("key");
}
Also used : ProjectRepositoriesProvider(org.sonar.scanner.repository.ProjectRepositoriesProvider) FileData(org.sonar.scanner.repository.FileData) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) Date(java.util.Date) Before(org.junit.Before)

Example 2 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectRepositoriesProviderTest method testAssociated.

@Test
public void testAssociated() {
    when(mode.isIssues()).thenReturn(false);
    when(loader.load(eq("key"), eq(false))).thenReturn(project);
    ProjectRepositories repo = provider.provide(loader, projectKey, mode);
    assertThat(repo.exists()).isEqualTo(true);
    assertThat(repo.lastAnalysisDate()).isNotNull();
    verify(mode, times(2)).isIssues();
    verify(projectKey).get();
    verify(loader).load(eq("key"), eq(false));
    verifyNoMoreInteractions(loader, projectKey, mode);
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) Test(org.junit.Test)

Example 3 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ModuleSettingsTest method test_loading_of_parent_module_settings_for_new_module.

// SONAR-6386
@Test
public void test_loading_of_parent_module_settings_for_new_module() {
    GlobalSettings globalSettings = newGlobalSettings(ImmutableMap.of("overridding", "batch", "on-batch", "true"));
    ProjectRepositories projRepos = createSettings("struts", ImmutableMap.of("on-module", "true", "overridding", "module"));
    ProjectDefinition module = ProjectDefinition.create().setKey("struts-core");
    ProjectDefinition.create().setKey("struts").addSubProject(module);
    ModuleSettings moduleSettings = new ModuleSettings(globalSettings, module, projRepos, mode, mock(AnalysisContextReportPublisher.class));
    assertThat(moduleSettings.getString("overridding")).isEqualTo("module");
    assertThat(moduleSettings.getString("on-batch")).isEqualTo("true");
    assertThat(moduleSettings.getString("on-module")).isEqualTo("true");
}
Also used : GlobalSettings(org.sonar.scanner.bootstrap.GlobalSettings) AnalysisContextReportPublisher(org.sonar.scanner.report.AnalysisContextReportPublisher) ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Test(org.junit.Test)

Example 4 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_not_fail_when_accessing_secured_properties.

@Test
public void should_not_fail_when_accessing_secured_properties() {
    Table<String, String, String> settings = HashBasedTable.create();
    settings.put("struts", "sonar.foo.secured", "bar");
    settings.put("struts", "sonar.foo.license.secured", "bar2");
    projectRef = new ProjectRepositories(settings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    assertThat(batchSettings.getString("sonar.foo.secured")).isEqualTo("bar");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 5 with ProjectRepositories

use of org.sonar.scanner.repository.ProjectRepositories in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_load_project_root_settings_on_branch.

@Test
public void should_load_project_root_settings_on_branch() {
    project.setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "mybranch");
    Table<String, String, String> settings = HashBasedTable.create();
    settings.put("struts:mybranch", "sonar.cpd.cross", "true");
    settings.put("struts:mybranch", "sonar.java.coveragePlugin", "jacoco");
    projectRef = new ProjectRepositories(settings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Aggregations

ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)12 Test (org.junit.Test)11 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)5 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)4 GlobalSettings (org.sonar.scanner.bootstrap.GlobalSettings)4 AnalysisContextReportPublisher (org.sonar.scanner.report.AnalysisContextReportPublisher)4 Date (java.util.Date)1 Before (org.junit.Before)1 FileData (org.sonar.scanner.repository.FileData)1 ProjectRepositoriesProvider (org.sonar.scanner.repository.ProjectRepositoriesProvider)1 StatusDetection (org.sonar.scanner.scan.filesystem.StatusDetection)1