Search in sources :

Example 31 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class ProjectSettingsFactoryTest method project_settings_override_global_settings.

@Test
public void project_settings_override_global_settings() {
    settings.setProperty("key", "value");
    when(dbClient.propertiesDao().selectProjectProperties(PROJECT_KEY)).thenReturn(newArrayList(new PropertyDto().setKey("key").setValue("value2")));
    Settings projectSettings = underTest.newProjectSettings(PROJECT_KEY);
    assertThat(projectSettings.getString("key")).isEqualTo("value2");
}
Also used : PropertyDto(org.sonar.db.property.PropertyDto) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 32 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class ProjectSettingsFactoryTest method return_global_settings.

@Test
public void return_global_settings() {
    settings.setProperty("key", "value");
    Settings projectSettings = underTest.newProjectSettings(PROJECT_KEY);
    assertThat(projectSettings.getProperties()).hasSize(1);
    assertThat(projectSettings.getString("key")).isEqualTo("value");
}
Also used : Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Example 33 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class DeleteActionTest method setUp.

@Before
public void setUp() {
    defaultGroup = db.users().insertGroup(db.getDefaultOrganization(), CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE);
    Settings settings = new MapSettings().setProperty(CoreProperties.CORE_DEFAULT_GROUP, CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE);
    ws = new WsTester(new UserGroupsWs(new DeleteAction(db.getDbClient(), userSession, newGroupWsSupport(), settings, defaultOrganizationProvider)));
}
Also used : MapSettings(org.sonar.api.config.MapSettings) WsTester(org.sonar.server.ws.WsTester) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Before(org.junit.Before)

Example 34 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class DefaultHttpDownloaderTest method configure_http_proxy_credentials.

@Test
public void configure_http_proxy_credentials() {
    DefaultHttpDownloader.AuthenticatorFacade system = mock(DefaultHttpDownloader.AuthenticatorFacade.class);
    Settings settings = new MapSettings();
    settings.setProperty("https.proxyHost", "1.2.3.4");
    settings.setProperty("http.proxyUser", "the_login");
    settings.setProperty("http.proxyPassword", "the_passwd");
    new DefaultHttpDownloader.BaseHttpDownloader(system, settings, null);
    verify(system).setDefaultAuthenticator(argThat(new TypeSafeMatcher<Authenticator>() {

        @Override
        protected boolean matchesSafely(Authenticator authenticator) {
            DefaultHttpDownloader.ProxyAuthenticator a = (DefaultHttpDownloader.ProxyAuthenticator) authenticator;
            PasswordAuthentication authentication = a.getPasswordAuthentication();
            return authentication.getUserName().equals("the_login") && new String(authentication.getPassword()).equals("the_passwd");
        }

        @Override
        public void describeTo(Description description) {
        }
    }));
}
Also used : TypeSafeMatcher(org.hamcrest.TypeSafeMatcher) Description(org.hamcrest.Description) MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Authenticator(java.net.Authenticator) PasswordAuthentication(java.net.PasswordAuthentication) Test(org.junit.Test)

Example 35 with Settings

use of org.sonar.api.config.Settings in project sonarqube by SonarSource.

the class SensorContextTesterTest method testSettings.

@Test
public void testSettings() {
    Settings settings = new MapSettings();
    settings.setProperty("foo", "bar");
    tester.setSettings(settings);
    assertThat(tester.settings().getString("foo")).isEqualTo("bar");
}
Also used : MapSettings(org.sonar.api.config.MapSettings) Settings(org.sonar.api.config.Settings) MapSettings(org.sonar.api.config.MapSettings) Test(org.junit.Test)

Aggregations

Settings (org.sonar.api.config.Settings)52 MapSettings (org.sonar.api.config.MapSettings)43 Test (org.junit.Test)41 Before (org.junit.Before)5 Languages (org.sonar.api.resources.Languages)5 FileExclusions (org.sonar.api.scan.filesystem.FileExclusions)5 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)5 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)5 IndexedFile (org.sonar.api.batch.fs.IndexedFile)4 DefaultIndexedFile (org.sonar.api.batch.fs.internal.DefaultIndexedFile)4 File (java.io.File)3 String.format (java.lang.String.format)3 TransportClient (org.elasticsearch.client.transport.TransportClient)3 PropertyDto (org.sonar.db.property.PropertyDto)3 InetAddress (java.net.InetAddress)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Condition (org.assertj.core.api.Condition)2 TransportAddress (org.elasticsearch.common.transport.TransportAddress)2 Rule (org.junit.Rule)2 ExpectedException (org.junit.rules.ExpectedException)2