aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-12 16:35:36 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-01-16 11:38:43 +0100
commit58ab35cf448155dba75faa006057ab50b705c6e1 (patch)
treef83d29c1737de1f90efb879d06f3c13a28e95c1e
parent42ba2e62fccfe8da8e751313787eb1d759032fbe (diff)
downloadsonarqube-58ab35cf448155dba75faa006057ab50b705c6e1.tar.gz
sonarqube-58ab35cf448155dba75faa006057ab50b705c6e1.zip
SONAR-8617 add organization to api/navigation/component response
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java2
-rw-r--r--server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json1
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java7
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json1
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json1
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json1
-rw-r--r--server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json1
7 files changed, 11 insertions, 3 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
index ffdb67f0734..de2a87197b9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
@@ -17,7 +17,6 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
package org.sonar.server.ui.ws;
import com.google.common.collect.Lists;
@@ -149,6 +148,7 @@ public class ComponentAction implements NavigationWsAction {
private void writeComponent(JsonWriter json, DbSession session, ComponentDto component, @Nullable SnapshotDto analysis) {
json.prop("key", component.key())
+ .prop("organization", component.getOrganizationKey())
.prop("id", component.uuid())
.prop("name", component.name())
.prop("description", component.description())
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json
index e797d034d47..b9275d0bd22 100644
--- a/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json
+++ b/server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json
@@ -1,4 +1,5 @@
{
+ "organization": "my-org-1",
"key": "org.codehaus.sonar:sonar",
"id": "ABCD",
"name": "Sonarqube",
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
index bd47de25716..e349965caba 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
@@ -42,6 +42,7 @@ import org.sonar.db.component.ComponentDbTester;
import org.sonar.db.component.ComponentDto;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.metric.MetricDto;
+import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.property.PropertyDbTester;
import org.sonar.db.property.PropertyDto;
import org.sonar.db.qualitygate.QualityGateDto;
@@ -106,7 +107,8 @@ public class ComponentActionTest {
@Before
public void before() {
- project = newProjectDto(dbTester.getDefaultOrganization(), "abcd")
+ OrganizationDto organization = dbTester.organizations().insertForKey("my-org");
+ project = newProjectDto(organization, "abcd")
.setKey(PROJECT_KEY)
.setName("Polop")
.setDescription("test project")
@@ -340,7 +342,8 @@ public class ComponentActionTest {
@Test
public void test_example_response() throws Exception {
init(createPages());
- ComponentDto project = newProjectDto(dbTester.getDefaultOrganization(), "ABCD")
+ OrganizationDto organizationDto = dbTester.organizations().insertForKey("my-org-1");
+ ComponentDto project = newProjectDto(organizationDto, "ABCD")
.setKey("org.codehaus.sonar:sonar")
.setName("Sonarqube")
.setDescription("Open source platform for continuous inspection of code quality");
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json
index fe5e8663833..5cbe3a1586d 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json
@@ -1,4 +1,5 @@
{
+ "organization": "my-org",
"key": "palap:src/main/xoo/Source.xoo",
"id": "cdef",
"name": "Source.xoo",
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json
index ede37f60c36..6fe16e2a308 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json
@@ -1,4 +1,5 @@
{
+ "organization": "my-org",
"key": "polop",
"id": "abcd",
"name": "Polop",
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json
index 90752cb430a..1303f9901d9 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json
@@ -1,4 +1,5 @@
{
+ "organization": "my-org",
"key": "polop",
"id": "abcd",
"name": "Polop",
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json
index 1eea2061ade..45aea77e5fa 100644
--- a/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json
+++ b/server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json
@@ -1,4 +1,5 @@
{
+ "organization": "my-org",
"key": "polop",
"id": "abcd",
"name": "Polop",