Search in sources :

Example 6 with Configuration

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

the class ComponentIssuesLoaderTest method loadClosedIssues_returns_empty_without_querying_DB_if_property_is_0.

@Test
public void loadClosedIssues_returns_empty_without_querying_DB_if_property_is_0() {
    System2 system2 = mock(System2.class);
    DbClient dbClient = mock(DbClient.class);
    Configuration configuration = newConfiguration("0");
    String componentUuid = randomAlphabetic(15);
    ComponentIssuesLoader underTest = new ComponentIssuesLoader(dbClient, null, /* not used in loadClosedIssues */
    null, /* not used in loadClosedIssues */
    configuration, system2);
    assertThat(underTest.loadClosedIssues(componentUuid)).isEmpty();
    verifyZeroInteractions(dbClient, system2);
}
Also used : DbClient(org.sonar.db.DbClient) Configuration(org.sonar.api.config.Configuration) System2(org.sonar.api.utils.System2) Test(org.junit.Test)

Example 7 with Configuration

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

the class ComponentIssuesLoaderTest method loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago_if_property_is_empty.

@Test
public void loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago_if_property_is_empty() {
    Configuration configuration = newConfiguration(null);
    ComponentIssuesLoader underTest = newComponentIssuesLoader(configuration);
    loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago(underTest);
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test)

Example 8 with Configuration

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

the class ComponentIssuesLoaderTest method loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_30.

@Test
public void loadClosedIssues_returns_only_closed_with_close_date_is_from_30_days_ago_if_property_is_30() {
    Configuration configuration = newConfiguration("30");
    ComponentIssuesLoader underTest = newComponentIssuesLoader(configuration);
    loadClosedIssues_returns_only_closed_issues_with_close_date_is_from_30_days_ago(underTest);
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test)

Example 9 with Configuration

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

the class IndexDefinitionHashTest method hash_changes_if_refreshInterval_changes.

@Test
public void hash_changes_if_refreshInterval_changes() {
    Index index = Index.simple("foo");
    IndexMainType mainType = IndexMainType.main(index, "bar");
    Configuration emptySettings = new MapSettings().asConfig();
    SettingsConfiguration defaultRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).build();
    SettingsConfiguration noRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(-1).build();
    SettingsConfiguration refreshInterval30 = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(30).build();
    SettingsConfiguration someRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(56).build();
    assertThat(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, refreshInterval30))).isNotEqualTo(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
    assertThat(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
}
Also used : SettingsConfiguration(org.sonar.server.es.newindex.SettingsConfiguration) Configuration(org.sonar.api.config.Configuration) MapSettings(org.sonar.api.config.internal.MapSettings) SettingsConfiguration(org.sonar.server.es.newindex.SettingsConfiguration) TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) IndexMainType(org.sonar.server.es.IndexType.IndexMainType) TestNewIndex(org.sonar.server.es.newindex.TestNewIndex) Test(org.junit.Test)

Example 10 with Configuration

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

the class ConfigurationProviderTest method getStringArray_on_multivalue_properties_ignores_subsequent_commas_differently_from_Settings.

@Test
@UseDataProvider("subsequentCommas3")
public void getStringArray_on_multivalue_properties_ignores_subsequent_commas_differently_from_Settings(String subsequentCommas, String[] expected) {
    settings.setProperty(multivalueKey, subsequentCommas);
    Configuration configuration = underTest.provide(settings);
    getStringArrayBehaviorDiffers(configuration, multivalueKey, expected);
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Aggregations

Configuration (org.sonar.api.config.Configuration)47 Test (org.junit.Test)40 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)14 ComponentDto (org.sonar.db.component.ComponentDto)12 QGChangeEvent (org.sonar.server.qualitygate.changeevent.QGChangeEvent)7 MapSettings (org.sonar.api.config.internal.MapSettings)5 SnapshotDto (org.sonar.db.component.SnapshotDto)4 PropertyDefinitions (org.sonar.api.config.PropertyDefinitions)3 Encryption (org.sonar.api.config.internal.Encryption)3 Metric (org.sonar.api.measures.Metric)3 DefaultBranchImpl (org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl)3 HashSet (java.util.HashSet)2 DbClient (org.sonar.db.DbClient)2 BranchDto (org.sonar.db.component.BranchDto)2 LiveMeasureDto (org.sonar.db.measure.LiveMeasureDto)2 MetricDto (org.sonar.db.metric.MetricDto)2 ProjectDto (org.sonar.db.project.ProjectDto)2 EvaluatedQualityGate (org.sonar.server.qualitygate.EvaluatedQualityGate)2 QualityGate (org.sonar.server.qualitygate.QualityGate)2 File (java.io.File)1