use of org.sonar.server.qualitygate.changeevent.QGChangeEvent 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());
}
use of org.sonar.server.qualitygate.changeevent.QGChangeEvent 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);
}
use of org.sonar.server.qualitygate.changeevent.QGChangeEvent 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);
}
use of org.sonar.server.qualitygate.changeevent.QGChangeEvent in project sonarqube by SonarSource.
the class LiveMeasureComputerImplTest method variation_is_refreshed_when_rating_value_is_changed.
@Test
public void variation_is_refreshed_when_rating_value_is_changed() {
markProjectAsAnalyzed(project);
// value is:
// B on last analysis
// D on beginning of leak period --> variation is -2
db.measures().insertLiveMeasure(project, ratingMetric, m -> m.setValue((double) Rating.B.getIndex()).setData("B").setVariation(-2.0));
// new value is C, so variation on leak period is D to C = -1
List<QGChangeEvent> result = run(file1, newRatingConstantFormula(Rating.C));
LiveMeasureDto measure = assertThatRatingMeasureHasValue(project, Rating.C);
assertThat(measure.getVariation()).isEqualTo(-1.0);
assertThatProjectChanged(result, project);
}
use of org.sonar.server.qualitygate.changeevent.QGChangeEvent in project sonarqube by SonarSource.
the class LiveMeasureComputerImplTest method variation_does_not_change_if_rating_value_does_not_change.
@Test
public void variation_does_not_change_if_rating_value_does_not_change() {
markProjectAsAnalyzed(project);
// value is:
// B on last analysis
// D on beginning of leak period --> variation is -2
db.measures().insertLiveMeasure(project, ratingMetric, m -> m.setValue((double) Rating.B.getIndex()).setData("B").setVariation(-2.0));
// new value is still B, so variation on leak period is still -2
List<QGChangeEvent> result = run(file1, newRatingConstantFormula(Rating.B));
LiveMeasureDto measure = assertThatRatingMeasureHasValue(project, Rating.B);
assertThat(measure.getVariation()).isEqualTo(-2.0);
assertThatProjectChanged(result, project);
}
Aggregations