org.sonar.api.config.Settings.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.sonar.api.config.Settings.setProperty()方法的一些代码示例,展示了Settings.setProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.setProperty()方法的具体详情如下:
包路径:org.sonar.api.config.Settings
类名称:Settings
方法名:setProperty

Settings.setProperty介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

/**
 * @see #setProperty(String, String)
 */
public Settings setProperty(String key, @Nullable Date date) {
 return setProperty(key, date, false);
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * @see #setProperty(String, String)
 */
public Settings setProperty(String key, @Nullable Long value) {
 return setProperty(key, value == null ? null : String.valueOf(value));
}

代码示例来源:origin: SonarSource/sonarqube

public Settings appendProperty(String key, @Nullable String value) {
 Optional<String> existingValue = getRawString(definitions.validKey(key));
 String newValue;
 if (!existingValue.isPresent()) {
  newValue = trim(value);
 } else {
  newValue = existingValue.get() + "," + trim(value);
 }
 return setProperty(key, newValue);
}

代码示例来源:origin: SonarSource/sonarqube

private void addSettings(Settings settings, String componentDbKey) {
  dbClient.propertiesDao()
   .selectProjectProperties(componentDbKey)
   .forEach(property -> settings.setProperty(property.getKey(), property.getValue()));
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void set_property_boolean() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", true);
 settings.setProperty("bar", false);
 assertThat(settings.getBoolean("foo")).isTrue();
 assertThat(settings.getBoolean("bar")).isFalse();
 assertThat(settings.getString("foo")).isEqualTo("true");
 assertThat(settings.getString("bar")).isEqualTo("false");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void set_property_int() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", 123);
 assertThat(settings.getInt("foo")).isEqualTo(123);
 assertThat(settings.getString("foo")).isEqualTo("123");
 assertThat(settings.getBoolean("foo")).isFalse();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void all_values_should_be_trimmed_set_property() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", "   FOO ");
 assertThat(settings.getString("foo")).isEqualTo("FOO");
}

代码示例来源:origin: SonarSource/sonarqube

@Test(expected = IllegalStateException.class)
public void shouldFailToSetArrayValueOnSingleValueProperty() {
 Settings settings = new MapSettings(definitions);
 settings.setProperty("array", new String[] {"A", "B", "C"});
}

代码示例来源:origin: SonarSource/sonarqube

private void verifyObfuscated(String key) {
 settings.setProperty(key, "foo");
 ProtobufSystemInfo.Section protobuf = underTest.toProtobuf();
 assertThatAttributeIs(protobuf, key, "xxxxxxxx");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldGuessDefaultDriver() {
 Settings settings = new MapSettings();
 settings.setProperty("sonar.jdbc.url", "jdbc:postgresql://localhost/sonar");
 DefaultDatabase database = new DefaultDatabase(logbackHelper, settings);
 database.initSettings();
 assertThat(database.getProperties().getProperty("sonar.jdbc.driverClassName")).isEqualTo("org.postgresql.Driver");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void setStringArray() {
 Settings settings = new MapSettings(definitions);
 settings.setProperty("multi_values", new String[] {"A", "B"});
 String[] array = settings.getStringArray("multi_values");
 assertThat(array).isEqualTo(new String[] {"A", "B"});
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void testSetNullDouble() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", (Double) null);
 assertThat(settings.getDouble("foo")).isNull();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void setStringArrayWithNullValues() {
 Settings settings = new MapSettings(definitions);
 settings.setProperty("multi_values", new String[] {"A,B", null, "C,D"});
 String[] array = settings.getStringArray("multi_values");
 assertThat(array).isEqualTo(new String[] {"A,B", "", "C,D"});
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldTrimArray() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", "  one,  two, three  ");
 String[] array = settings.getStringArray("foo");
 assertThat(array).isEqualTo(new String[] {"one", "two", "three"});
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_get_float() {
 Settings settings = new MapSettings();
 settings.setProperty("from_float", 3.14159f);
 settings.setProperty("from_string", "3.14159");
 assertThat(settings.getDouble("from_float")).isEqualTo(3.14159f, Offset.offset(0.00001));
 assertThat(settings.getDouble("from_string")).isEqualTo(3.14159f, Offset.offset(0.00001));
 assertThat(settings.getDouble("unknown")).isNull();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_load_values_of_deprecated_key() {
 Settings settings = new MapSettings(definitions);
 settings.setProperty("oldKey", "a,b");
 assertThat(settings.getStringArray("newKey")).containsOnly("a", "b");
 assertThat(settings.getStringArray("oldKey")).containsOnly("a", "b");
}

代码示例来源:origin: SonarSource/sonarqube

@Test(expected = RuntimeException.class)
 public void invalid_startup_date_throws_exception() {
  Settings settings = new MapSettings();
  settings.setProperty(CoreProperties.SERVER_STARTTIME, "invalid");
  ScannerWsClient client = mock(ScannerWsClient.class);
  DefaultServer metadata = new DefaultServer(((MapSettings) settings).asConfig(), client, null);
  metadata.getStartedAt();
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void set_property_string_array_trims_key() {
 String key = randomAlphanumeric(3);
 Settings underTest = new MapSettings(new PropertyDefinitions(singletonList(PropertyDefinition.builder(key).multiValues(true).build())));
 Random random = new Random();
 String blankBefore = blank(random);
 String blankAfter = blank(random);
 underTest.setProperty(blankBefore + key + blankAfter, new String[] {"1", "2"});
 assertThat(underTest.hasKey(key)).isTrue();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_get_bad_double() {
 Settings settings = new MapSettings();
 settings.setProperty("foo", "bar");
 thrown.expect(IllegalStateException.class);
 thrown.expectMessage("The property 'foo' is not a double value");
 settings.getDouble("foo");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void set_property_string_throws_NPE_if_key_is_null() {
 String key = randomAlphanumeric(3);
 Settings underTest = new MapSettings(new PropertyDefinitions(singletonList(PropertyDefinition.builder(key).multiValues(true).build())));
 expectKeyNullNPE();
 underTest.setProperty(null, new String[] {"1", "2"});
}

相关文章