Search in sources :

Example 11 with ValuesWsResponse

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

the class ValuesActionTest method return_global_settings_from_definitions_when_no_component_and_no_keys.

@Test
public void return_global_settings_from_definitions_when_no_component_and_no_keys() throws Exception {
    logInAsAdmin();
    definitions.addComponents(asList(PropertyDefinition.builder("foo").build(), PropertyDefinition.builder("secret.secured").build(), PropertyDefinition.builder("plugin.license.secured").type(LICENSE).build()));
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("foo").setValue("one"), newGlobalPropertyDto().setKey("secret.secured").setValue("password"), newGlobalPropertyDto().setKey("plugin.license.secured").setValue("ABCD"));
    ValuesWsResponse result = executeRequestForGlobalProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey).containsOnly("foo", "secret.secured", "plugin.license.secured");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 12 with ValuesWsResponse

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

the class ValuesActionTest method return_nothing_when_unknown_keys.

@Test
public void return_nothing_when_unknown_keys() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("foo").defaultValue("default").build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("bar").setValue(""));
    ValuesWsResponse result = executeRequestForGlobalProperties("unknown");
    assertThat(result.getSettingsList()).isEmpty();
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Test(org.junit.Test)

Example 13 with ValuesWsResponse

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

the class ValuesActionTest method return_settings_defined_only_at_global_level_when_loading_project_settings.

@Test
public void return_settings_defined_only_at_global_level_when_loading_project_settings() throws Exception {
    logInAsProjectUser();
    definitions.addComponents(asList(PropertyDefinition.builder("global").build(), PropertyDefinition.builder("global.default").defaultValue("default").build(), PropertyDefinition.builder("project").onQualifiers(PROJECT).build()));
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("one"), newComponentPropertyDto(project).setKey("project").setValue("two"));
    ValuesWsResponse result = executeRequestForProjectProperties();
    assertThat(result.getSettingsList()).extracting(Settings.Setting::getKey, Settings.Setting::getValue).containsOnly(tuple("project", "two"), tuple("global.default", "default"), tuple("global", "one"));
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 14 with ValuesWsResponse

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

the class ValuesActionTest method return_multi_values.

@Test
public void return_multi_values() throws Exception {
    logIn();
    // Property never defined, default value is returned
    definitions.addComponent(PropertyDefinition.builder("default").multiValues(true).defaultValue("one,two").build());
    // Property defined at global level
    definitions.addComponent(PropertyDefinition.builder("global").multiValues(true).build());
    propertyDb.insertProperties(newGlobalPropertyDto().setKey("global").setValue("three,four"));
    ValuesWsResponse result = executeRequestForGlobalProperties("default", "global");
    assertThat(result.getSettingsList()).hasSize(2);
    Settings.Setting foo = result.getSettings(0);
    assertThat(foo.getKey()).isEqualTo("default");
    assertThat(foo.getValues().getValuesList()).containsOnly("one", "two");
    Settings.Setting bar = result.getSettings(1);
    assertThat(bar.getKey()).isEqualTo("global");
    assertThat(bar.getValues().getValuesList()).containsOnly("three", "four");
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

Example 15 with ValuesWsResponse

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

the class ValuesActionTest method return_property_set.

@Test
public void return_property_set() throws Exception {
    logIn();
    definitions.addComponent(PropertyDefinition.builder("foo").type(PropertyType.PROPERTY_SET).fields(asList(PropertyFieldDefinition.build("key").name("Key").build(), PropertyFieldDefinition.build("size").name("Size").build())).build());
    propertyDb.insertPropertySet("foo", null, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
    ValuesWsResponse result = executeRequestForGlobalProperties("foo");
    assertThat(result.getSettingsList()).hasSize(1);
    Settings.Setting value = result.getSettings(0);
    assertThat(value.getKey()).isEqualTo("foo");
    assertFieldValues(value, ImmutableMap.of("key", "key1", "size", "size1"), ImmutableMap.of("key", "key2"));
}
Also used : ValuesWsResponse(org.sonarqube.ws.Settings.ValuesWsResponse) Settings(org.sonarqube.ws.Settings) Test(org.junit.Test)

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