aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2017-10-24 11:26:59 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2017-10-24 14:21:12 +0200
commit333feeb200ced5246182208bc72944cd4e11ce85 (patch)
treebdb4ba321673b6c39d5f99324a40afa235ce4699
parent95d91e6fff76d8561e5d9dd71379dde8bc6258fa (diff)
downloadsonarqube-333feeb200ced5246182208bc72944cd4e11ce85.tar.gz
sonarqube-333feeb200ced5246182208bc72944cd4e11ce85.zip
SONAR-9869 Fix project urls in webhook payload
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java12
-rw-r--r--tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java3
3 files changed, 10 insertions, 9 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java b/server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
index f70e4683a8e..9f4c0ca5015 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/webhook/WebhookPayloadFactoryImpl.java
@@ -110,7 +110,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
}
private String projectUrlOf(Project project) {
- return format("%s/project/dashboard?id=%s", server.getPublicRootUrl(), encode(project.getKey()));
+ return format("%s/dashboard?id=%s", server.getPublicRootUrl(), encode(project.getKey()));
}
private String branchUrlOf(Project project, Branch branch) {
@@ -118,7 +118,7 @@ public class WebhookPayloadFactoryImpl implements WebhookPayloadFactory {
if (branch.isMain()) {
return projectUrlOf(project);
}
- return format("%s/project/dashboard?branch=%s&id=%s",
+ return format("%s/dashboard?branch=%s&id=%s",
server.getPublicRootUrl(), encode(branch.getName().orElse("")), encode(project.getKey()));
} else {
return format("%s/project/issues?branch=%s&id=%s&resolved=false",
diff --git a/server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java b/server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
index d9239b774b0..05501d9e366 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/webhook/WebhookPayloadFactoryImplTest.java
@@ -69,7 +69,7 @@ public class WebhookPayloadFactoryImplTest {
" \"project\": {" +
" \"key\": \"P1\"," +
" \"name\": \"Project One\"," +
- " \"url\": \"http://foo/project/dashboard?id=P1\"" +
+ " \"url\": \"http://foo/dashboard?id=P1\"" +
" }," +
" \"qualityGate\": {" +
" \"name\": \"Gate One\"," +
@@ -110,7 +110,7 @@ public class WebhookPayloadFactoryImplTest {
" \"project\": {" +
" \"key\": \"P1\"," +
" \"name\": \"Project One\"," +
- " \"url\": \"http://foo/project/dashboard?id=P1\"" +
+ " \"url\": \"http://foo/dashboard?id=P1\"" +
" }," +
" \"qualityGate\": {" +
" \"name\": \"Gate One\"," +
@@ -151,7 +151,7 @@ public class WebhookPayloadFactoryImplTest {
" \"project\": {" +
" \"key\": \"P1\"," +
" \"name\": \"Project One\"," +
- " \"url\": \"http://foo/project/dashboard?id=P1\"" +
+ " \"url\": \"http://foo/dashboard?id=P1\"" +
" }," +
" \"qualityGate\": {" +
" \"name\": \"Gate One\"," +
@@ -186,7 +186,7 @@ public class WebhookPayloadFactoryImplTest {
" \"project\": {" +
" \"key\": \"P1\"," +
" \"name\": \"Project One\"," +
- " \"url\": \"http://foo/project/dashboard?id=P1\"" +
+ " \"url\": \"http://foo/dashboard?id=P1\"" +
" }," +
" \"properties\": {" +
" }" +
@@ -266,7 +266,7 @@ public class WebhookPayloadFactoryImplTest {
" \"name\": \"feature/foo\"" +
" \"type\": \"LONG\"" +
" \"isMain\": false," +
- " \"url\": \"http://foo/project/dashboard?branch=feature%2Ffoo&id=P1\"" +
+ " \"url\": \"http://foo/dashboard?branch=feature%2Ffoo&id=P1\"" +
"}" +
"}");
}
@@ -282,7 +282,7 @@ public class WebhookPayloadFactoryImplTest {
"\"branch\": {" +
" \"type\": \"LONG\"" +
" \"isMain\": true," +
- " \"url\": \"http://foo/project/dashboard?id=P1\"" +
+ " \"url\": \"http://foo/dashboard?id=P1\"" +
"}" +
"}");
}
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 2539ab6bb6d..16d2ec83f88 100644
--- a/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/webhook/WebhooksTest.java
@@ -20,7 +20,6 @@
package org.sonarqube.tests.webhook;
import com.sonar.orchestrator.Orchestrator;
-import org.sonarqube.tests.Category3Suite;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -31,6 +30,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
+import org.sonarqube.tests.Category3Suite;
import org.sonarqube.ws.Webhooks;
import org.sonarqube.ws.client.HttpException;
import org.sonarqube.ws.client.WsClient;
@@ -107,6 +107,7 @@ public class WebhooksTest {
Map<String, String> project = (Map<String, String>) payload.get("project");
assertThat(project.get("key")).isEqualTo(PROJECT_KEY);
assertThat(project.get("name")).isEqualTo(PROJECT_NAME);
+ assertThat(project.get("url")).isEqualTo(orchestrator.getServer().getUrl() + "/dashboard?id=" + PROJECT_KEY);
Map<String, Object> gate = (Map<String, Object>) payload.get("qualityGate");
assertThat(gate.get("name")).isEqualTo("SonarQube way");
assertThat(gate.get("status")).isEqualTo("OK");