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");
}
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();
}
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"));
}
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");
}
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"));
}
Aggregations