Search in sources :

Example 6 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_inherited_values_on_module.

@Test
public void return_inherited_values_on_module() throws Exception {
    logInAsProjectUser();
    ComponentDto module = componentDb.insertComponent(newModuleDto(project));
    definitions.addComponents(asList(PropertyDefinition.builder("defaultProperty").defaultValue("default").onQualifiers(PROJECT, MODULE).build(), PropertyDefinition.builder("globalProperty").onQualifiers(PROJECT, MODULE).build(), PropertyDefinition.builder("projectProperty").onQualifiers(PROJECT, MODULE).build(), PropertyDefinition.builder("moduleProperty").onQualifiers(PROJECT, MODULE).build()));
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("globalProperty").setValue("global"), newComponentPropertyDto(project).setKey("projectProperty").setValue("project"), newComponentPropertyDto(module).setKey("moduleProperty").setValue("module"));
    ValuesWsResponse result = executeRequestForComponentProperties(module, "defaultProperty", "globalProperty", "projectProperty", "moduleProperty");
    assertThat(result.getSettingsList()).hasSize(4);
    assertSetting(result.getSettings(0), "defaultProperty", "default", true);
    assertSetting(result.getSettings(1), "globalProperty", "global", true);
    assertSetting(result.getSettings(2), "projectProperty", "project", true);
    assertSetting(result.getSettings(3), "moduleProperty", "module", false);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 7 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_project_values.

@Test
public void return_project_values() throws Exception {
    logInAsProjectUser();
    definitions.addComponent(PropertyDefinition.builder("property").defaultValue("default").onQualifiers(PROJECT).build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("property").setValue("one"), // The property is overriding global value
    newComponentPropertyDto(project).setKey("property").setValue("two"));
    ValuesWsResponse result = executeRequestForProjectProperties("property");
    assertThat(result.getSettingsList()).hasSize(1);
    assertSetting(result.getSettings(0), "property", "two", false);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 8 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class ValuesActionTest method return_simple_value_with_non_ascii_characters.

@Test
public void return_simple_value_with_non_ascii_characters() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("foo").build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("fi±∞…"));
    ValuesWsResponse result = executeRequestForGlobalProperties("foo");
    assertThat(result.getSettings(0).getValue()).isEqualTo("fi±∞…");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 9 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class LicensesPageTest method change_licenses.

@Test
public void change_licenses() {
    String EXAMPLE_LICENSE = "TmFtZTogRGV2ZWxvcHBlcnMKUGx1Z2luOiBhdXRvY29udHJvbApFeHBpcmVzOiAyMDEyLTA0LTAxCktleTogNjI5N2MxMzEwYzg2NDZiZTE5MDU1MWE4ZmZmYzk1OTBmYzEyYTIyMgo=";
    LicensesPage page = nav.logIn().asAdmin().openLicenses();
    LicenseItem licenseItem = page.getLicenseByKey("typed.license.secured");
    licenseItem.setLicense(EXAMPLE_LICENSE);
    ValuesWsResponse response = wsClient.settingsService().values(ValuesRequest.builder().setKeys("typed.license.secured").build());
    assertThat(response.getSettings(0).getValue()).isEqualTo(EXAMPLE_LICENSE);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) LicensesPage(pageobjects.licenses.LicensesPage) LicenseItem(pageobjects.licenses.LicenseItem) Test(org.junit.Test)

Example 10 with ValuesWsResponse

use of org.sonarqube.ws.Settings.ValuesWsResponse in project sonarqube by SonarSource.

the class SettingsTest method getSetting.

@CheckForNull
private static Setting getSetting(String key, SettingsService settingsService) {
    ValuesWsResponse response = settingsService.values(ValuesRequest.builder().setKeys(key).build());
    List<Settings.Setting> settings = response.getSettingsList();
    return settings.isEmpty() ? null : settings.get(0);
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Setting(org.sonarqube.ws.Settings.Setting) CheckForNull(javax.annotation.CheckForNull)

Aggregations

ValuesWsResponse (org.sonarqube.ws.Settings.ValuesWsResponse)34 Test (org.junit.Test)32 Settings (org.sonarqube.ws.Settings)19 ComponentDto (org.sonar.db.component.ComponentDto)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 CheckForNull (javax.annotation.CheckForNull)1 Profiler (org.sonar.api.utils.log.Profiler)1 Setting (org.sonarqube.ws.Settings.Setting)1 GetRequest (org.sonarqube.ws.client.GetRequest)1 LicenseItem (pageobjects.licenses.LicenseItem)1 LicensesPage (pageobjects.licenses.LicensesPage)1