Search in sources :

Example 16 with Configuration

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

the class ConfigurationProviderTest method getStringArray_on_multivalue_properties_ignores_empty_fields_differently_from_settings.

@Test
@UseDataProvider("emptyFields3")
public void getStringArray_on_multivalue_properties_ignores_empty_fields_differently_from_settings(String emptyFields, String[] expected) {
    settings.setProperty(multivalueKey, emptyFields);
    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)

Example 17 with Configuration

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

the class ConfigurationProviderTest method getStringArray_supports_quoted_strings_when_settings_does_not.

@Test
@UseDataProvider("quotedStrings1")
public void getStringArray_supports_quoted_strings_when_settings_does_not(String str, String[] configurationExpected, String[] settingsExpected) {
    settings.setProperty(nonDeclaredKey, str);
    settings.setProperty(nonMultivalueKey, str);
    settings.setProperty(multivalueKey, str);
    Configuration configuration = underTest.provide(settings);
    getStringArrayBehaviorDiffers(configuration, nonDeclaredKey, configurationExpected, settingsExpected);
    getStringArrayBehaviorDiffers(configuration, nonMultivalueKey, configurationExpected, settingsExpected);
    getStringArrayBehaviorDiffers(configuration, multivalueKey, configurationExpected, settingsExpected);
}
Also used : Configuration(org.sonar.api.config.Configuration) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 18 with Configuration

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

the class WebhookQGChangeEventListenerTest method onIssueChangesCallsWebhookOnBranch.

public void onIssueChangesCallsWebhookOnBranch(BranchType branchType) {
    ProjectAndBranch nonMainBranch = insertBranch(branchType, "foo");
    SnapshotDto analysis = insertAnalysisTask(nonMainBranch);
    Configuration configuration = mock(Configuration.class);
    QGChangeEvent qualityGateEvent = newQGChangeEvent(nonMainBranch, analysis, configuration, null);
    mockWebhookEnabled(qualityGateEvent.getProject());
    underTest.onIssueChanges(qualityGateEvent, CHANGED_ISSUES_ARE_IGNORED);
    verifyWebhookCalled(nonMainBranch, analysis, qualityGateEvent.getProject());
}
Also used : Configuration(org.sonar.api.config.Configuration) SnapshotDto(org.sonar.db.component.SnapshotDto) QGChangeEvent(org.sonar.server.qualitygate.changeevent.QGChangeEvent)

Example 19 with Configuration

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

the class WebhookQGChangeEventListenerTest method onIssueChanges_has_no_effect_if_event_has_neither_previousQGStatus_nor_qualityGate.

@Test
public void onIssueChanges_has_no_effect_if_event_has_neither_previousQGStatus_nor_qualityGate() {
    Configuration configuration = mock(Configuration.class);
    QGChangeEvent qualityGateEvent = newQGChangeEvent(configuration, null, null);
    mockWebhookEnabled(qualityGateEvent.getProject());
    underTest.onIssueChanges(qualityGateEvent, CHANGED_ISSUES_ARE_IGNORED);
    verifyZeroInteractions(webhookPayloadFactory, mockedDbClient);
}
Also used : Configuration(org.sonar.api.config.Configuration) QGChangeEvent(org.sonar.server.qualitygate.changeevent.QGChangeEvent) Test(org.junit.Test)

Example 20 with Configuration

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

the class WebhookQGChangeEventListenerTest method onIssueChanges_has_no_effect_if_event_has_same_status_in_previous_and_new_QG.

@Test
public void onIssueChanges_has_no_effect_if_event_has_same_status_in_previous_and_new_QG() {
    Configuration configuration = mock(Configuration.class);
    Metric.Level previousStatus = randomLevel();
    when(newQualityGate.getStatus()).thenReturn(previousStatus);
    QGChangeEvent qualityGateEvent = newQGChangeEvent(configuration, previousStatus, newQualityGate);
    mockWebhookEnabled(qualityGateEvent.getProject());
    underTest.onIssueChanges(qualityGateEvent, CHANGED_ISSUES_ARE_IGNORED);
    verifyZeroInteractions(webhookPayloadFactory, mockedDbClient);
}
Also used : Configuration(org.sonar.api.config.Configuration) Metric(org.sonar.api.measures.Metric) QGChangeEvent(org.sonar.server.qualitygate.changeevent.QGChangeEvent) Test(org.junit.Test)

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