aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-01-17 14:35:48 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-01-23 10:45:43 +0100
commit34471db69adf3ca56fe4c17496c6c82ac6036c97 (patch)
tree95aca581de2ad62ed9c66b0dc54cf3f911045892 /tests
parent1484ea4e115e549d260bb9fad2a6f114284dbd10 (diff)
downloadsonarqube-34471db69adf3ca56fe4c17496c6c82ac6036c97.tar.gz
sonarqube-34471db69adf3ca56fe4c17496c6c82ac6036c97.zip
SONAR-10247 do not call webhooks when QG status has not changed
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/Category3Suite.java1
-rw-r--r--tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java21
2 files changed, 20 insertions, 2 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/Category3Suite.java b/tests/src/test/java/org/sonarqube/tests/Category3Suite.java
index 0f066ca1de4..60fbc385ab8 100644
--- a/tests/src/test/java/org/sonarqube/tests/Category3Suite.java
+++ b/tests/src/test/java/org/sonarqube/tests/Category3Suite.java
@@ -92,6 +92,7 @@ public class Category3Suite {
// reduce memory for Elasticsearch to 128M
.setServerProperty("sonar.search.javaOpts", "-Xms128m -Xmx128m")
+// .setServerProperty("sonar.web.javaAdditionalOpts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
.build();
}
diff --git a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java
index 92c6bed436b..0bbed529135 100644
--- a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java
@@ -247,8 +247,9 @@ public class WebhooksTest {
waitUntilAllWebHooksCalled(1);
externalServer.clear();
- // change an issue to blocker bug
- Issue firstIssue = tester.wsClient().issues().search(new SearchRequest()).getIssues(0);
+ // change an issue to blocker bug, QG status goes from OK to ERROR, so webhook is called
+ List<Issue> issues = tester.wsClient().issues().search(new SearchRequest()).getIssuesList();
+ Issue firstIssue = issues.iterator().next();
tester.wsClient().issues().bulkChange(new BulkChangeRequest().setIssues(singletonList(firstIssue.getKey()))
.setSetSeverity(singletonList("BLOCKER"))
.setSetType(singletonList("BUG")));
@@ -268,6 +269,22 @@ public class WebhooksTest {
assertThat(gate.get("name")).isEqualTo(qGate.getName());
assertThat(gate.get("status")).isEqualTo("ERROR");
assertThat(gate.get("conditions")).isNotNull();
+ externalServer.clear();
+
+ // change severity of issue, won't change the QG status, so no webhook called
+ tester.wsClient().issues().bulkChange(new BulkChangeRequest().setIssues(singletonList(firstIssue.getKey()))
+ .setSetSeverity(singletonList("MINOR")));
+ waitUntilAllWebHooksCalled(1);
+ assertThat(externalServer.getPayloadRequests()).isEmpty();
+
+ // resolve issue as won't fix, QG status goes to OK, so webhook called
+ tester.wsClient().issues().bulkChange(new BulkChangeRequest().setIssues(singletonList(firstIssue.getKey()))
+ .setDoTransition("wontfix"));
+ waitUntilAllWebHooksCalled(1);
+ request = externalServer.getPayloadRequests().get(0);
+ payload = jsonToMap(request.getJson());
+ gate = (Map<String, Object>) payload.get("qualityGate");
+ assertThat(gate.get("status")).isEqualTo("OK");
}
private void analyseProject() {