@Test
@UseDataProvider("newQGorNot")
public void onIssueChanges_calls_webhook_for_changeEvent_with_webhook_enabled(@Nullable EvaluatedQualityGate newQualityGate) {
OrganizationDto organization = dbTester.organizations().insert();
ComponentDto project = dbTester.components().insertPublicProject(organization);
ComponentAndBranch branch = insertProjectBranch(project, BranchType.SHORT, "foo");
SnapshotDto analysis = insertAnalysisTask(branch);
Configuration configuration = mock(Configuration.class);
mockPayloadSupplierConsumedByWebhooks();
Map<String, String> properties = new HashMap<>();
properties.put("sonar.analysis.test1", randomAlphanumeric(50));
properties.put("sonar.analysis.test2", randomAlphanumeric(5000));
insertPropertiesFor(analysis.getUuid(), properties);
QGChangeEvent qualityGateEvent = newQGChangeEvent(branch, analysis, configuration, newQualityGate);
mockWebhookEnabled(qualityGateEvent.getProject());
underTest.onIssueChanges(qualityGateEvent, CHANGED_ISSUES_ARE_IGNORED);
ProjectAnalysis projectAnalysis = verifyWebhookCalledAndExtractPayloadFactoryArgument(branch, analysis, qualityGateEvent.getProject());
assertThat(projectAnalysis).isEqualTo(
new ProjectAnalysis(
new Project(project.uuid(), project.getKey(), project.name()),
null,
new Analysis(analysis.getUuid(), analysis.getCreatedAt()),
new Branch(false, "foo", Branch.Type.SHORT),
newQualityGate,
null,
properties));
}