]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8617 add organization to api/navigation/component response
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 12 Jan 2017 15:35:36 +0000 (16:35 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 16 Jan 2017 10:38:43 +0000 (11:38 +0100)
server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentAction.java
server/sonar-server/src/main/resources/org/sonar/server/ui/ws/component-example.json
server/sonar-server/src/test/java/org/sonar/server/ui/ws/ComponentActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_bread_crumbs_on_several_levels.json
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_anonymous_no_snapshot.json
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_when_snapshot.json
server/sonar-server/src/test/resources/org/sonar/server/ui/ws/ComponentActionTest/return_component_info_with_favourite.json

index ffdb67f07349571779ac93071363debd5c825afe..de2a87197b9badbe551509a3d1899d1615459c49 100644 (file)
@@ -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())
index e797d034d47187acb6d6e29672ff5a199c4c7811..b9275d0bd223e7c78b068f32c47989e8803ba662 100644 (file)
@@ -1,4 +1,5 @@
 {
+  "organization": "my-org-1",
   "key": "org.codehaus.sonar:sonar",
   "id": "ABCD",
   "name": "Sonarqube",
index bd47de25716199a898c6fad528d7eb1f3a2e6995..e349965caba1fc0b13e4efa308484114bc73d0d6 100644 (file)
@@ -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");